2662bcc60be42f6902efc30240573eccbe232dde
Generate .docx files with JS/TS very easily
=====
docx
A tool to create Word Documents (.docx) with JS or TS, written in TS.
Table of Contents
Install
$ npm install --save docx
Demo
$ npm run demo
will run the demo app in the demo
folder, which creates a file called "My Document.docx" in the root of the project
Guide
Please refer to the Wiki for details on how to use this library, examples and much more!
Usage
// Used to create docx files
var docx = require('docx');
// Create document
var doc = new docx.Document();
// Used to export the file into a .docx file
// res is express' Response object
var exporter = new docx.ExpressPacker(doc, res);
var exporter = new docx.LocalPacker(doc);
Create simple Word Document
var doc = new docx.Document();
var paragraph = new docx.Paragraph();
var text = new docx.TextRun('Hello World');
paragraph.addText(text);
doc.addParagraph(paragraph);
Document properties
You can add properties to the Word document by specifying options, for example:
var doc = new docx.Document({
creator: 'Dolan Miu',
description: 'My extremely interesting document',
title: 'My Document'
});
Full list of options:
creator
description
title
subject
keywords
lastModifiedBy
revision
You can mix and match whatever properties you want, or provide no properties.
Exporting
Check the Wiki for exporting guide
Examples
Check the Wiki for examples
=====
Made with 💖
Description
Languages
TypeScript
100%