Skip to content

📄 Create office documents with React

Notifications You must be signed in to change notification settings

divakarmanivel/reoffice

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reoffice

license status

Create office documents with React

Introduction

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.

Example

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!

Install

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

Usage

  • 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, run babel-node example.js. This will render your React component to word document.

Demo

git clone https://github.com/divakarmanivel/reoffice.git
cd reoffice
npm install
npm run example

Documentation

See the detailed documentation here

Contributing

See the Contributing guide here

License

MIT

About

📄 Create office documents with React

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%