Sometimes, we want to add a PowerPoint viewer into a React component.
In this article, we’ll look at how to add a PowerPoint viewer into a React component.
How to add a PowerPoint viewer into a React component?
To add a PowerPoint viewer into a React component, we can add a iframe that shows the PowerPoint slide’s with Microsoft’s online PowerPoint viewer.
For instance, we write:
import React from "react";
const linkToPPTFile =
"https://scholar.harvard.edu/files/torman_personal/files/samplepptx.pptx";
export default function App() {
return (
<>
<iframe
src={`https://view.officeapps.live.com/op/embed.aspx?src=${linkToPPTFile}`}
width="100%"
height="600px"
frameBorder="0"
title="slides"
></iframe>
</>
);
}
We want to show the PowerPoint presentation that’s located in the URL assigned to linkToPPTFile
.
To show the slides, we add an iframe with src
set to https://view.officeapps.live.com/op/embed.aspx?src=${linkToPPTFile}
.
We also set the width and height to set the dimensions.
And we set the frameBorder
to 0 to remove the iframe border.
Conclusion
To add a PowerPoint viewer into a React component, we can add a iframe that shows the PowerPoint slide’s with Microsoft’s online PowerPoint viewer.