Skip to content

nitin42/redocx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Nitin TulswaniNitin Tulswani
Nitin Tulswani
and
Nitin Tulswani
Dec 7, 2018
384305b Β· Dec 7, 2018
Nov 9, 2017
Dec 7, 2018
Oct 4, 2018
Nov 9, 2017
Oct 1, 2018
Dec 5, 2018
Aug 19, 2017
Aug 21, 2017
Aug 19, 2017
Aug 20, 2017
Sep 1, 2017
Dec 7, 2018
Sep 2, 2017
Dec 7, 2018

Repository files navigation

redocx

Build Status yarn license status

Create word documents with React

Introduction

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.

Example

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!

Install

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

Usage

  • Create a .babelrc
{
  "presets": [
    "env",
    "stage-0",
    "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/nitin42/redocx.git
cd redocx
npm install
npm run example

Documentation

See the detailed documentation here

Contributing

Contributing guide

License

MIT

Sponsor