Create office documents with React
reoffice
is a library which lets you create word documents with React. It provides a set of components which renders your declarative views and components to word documents.
This is a fork from redocx by Nitin Tulswani so all credits go to him. I have made changes to support all the updated packages like React 18 and Babel 7.
A simple component that renders a "Hello World" text to a word document.
import React from 'react'
import { render, Document, Text } from 'reoffice'
class App extends React.Component {
render() {
return (
<Document>
<Text>Hello World</Text>
</Document>
)
}
}
render(<App />, `${__dirname}/example.docx`)
Let's get started!
Babel presets and cli
npm install @babel-cli @babel-core @babel-preset-env @babel-preset-react --save-dev
react and reoffice
npm install react reoffice
- Create a
babel.config.json
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
}
- After configuring babel and assuming you've already created a file
example.js
with this example, runbabel-node example.js
. This will render your React component to word document.
git clone https://github.com/divakarmanivel/reoffice.git
cd reoffice
npm install
npm run example
See the detailed documentation here
See the Contributing guide here
MIT