nitin42 / redocx
- понедельник, 21 августа 2017 г. в 03:14:29
📄 Create word documents with React
Create word documents with React
redocx
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.
A simple component that renders a "Hello World" text to a word document.
import React from 'react'
import { render, Document, Text } from 'redocx'
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 --save-dev babel-cli babel-core babel-preset-env babel-preset-react babel-preset-stage-0
react and redocx
npm install --save react redocx
.babelrc
{
"presets": [
"env",
"stage-0",
"react"
]
}
example.js
with this example, run babel-node example.js
. This will render your React component to word document.
redocx
will soon have a new cli to automate this process making it easy to generate word documents with React!
git clone https://github.com/nitin42/redocx.git
cd redocx
npm install
npm run example
See the detailed documentation here
MIT