officegen
Creating Office Open XML files (Word, Excel and Powerpoint) for Microsoft Office 2007 and later without external tools, just pure Javascript. officegen should work on any environment that supports Node.js including Linux, OSX and Windows. officegen also supporting PowerPoint native charts objects with embedded data.
Contributors:
This project exists thanks to all the people who contribute.
Getting Started:
Officegen features overview:
- Generating Microsoft PowerPoint document (.pptx file):
- Create PowerPoint document with one or more slides.
- Support both PPT and PPS.
- Can create native charts.
- Add text blocks.
- Add images.
- Can declare fonts, alignment, colors and background.
- You can rotate objects.
- Support shapes: Ellipse, Rectangle, Line, Arrows, etc.
- Support hidden slides.
- Support automatic fields like date, time and current slide number.
- Support speaker notes.
- Support slide layouts.
- Generating Microsoft Word document (.docx file):
- Create Word document.
- You can add one or more paragraphs to the document and you can set the fonts, colors, alignment, etc.
- You can add images.
- Support header and footer.
- Support bookmarks and hyperlinks.
- Generating Microsoft Excel document (.xlsx file):
- Create Excel document with one or more sheets. Supporting cells with either numbers or strings.
Installation:
$ npm install officegen
Microsoft PowerPoint basic usage example:
const officegen = const fs = // Create an empty PowerPoint object:let pptx = // Officegen calling this function after finishing to generate the pptx document:pptx // Officegen calling this function to report errors:pptx // Let's add a title slide: let slide = pptx // Pie chart slide example: slide = pptxslidename = 'Pie Chart slide'slideback = 'ffff00'slide // Let's generate the PowerPoint document into a file: let out = fs out // Async call to generate the output file:pptx
Where to go from here?
- For more information please refer to the full documentation.
- For some examples please click here.
Microsoft Word basic usage example:
const officegen = const fs = // Create an empty Word object:let docx = // Officegen calling this function after finishing to generate the docx document:docx // Officegen calling this function to report errors:docx // Create a new paragraph:let pObj = docx pObjpObjpObj pObj = docx pObjpObj // Use pattern in the background.pObjpObj // Highlight!pObj // Different highlight color. pObj = docx pObjpObjpObj pObj = docx pObj pObj = docx pObj pObj = docxpObjoptionsalign = 'right' pObj pObj = docx pObjpObjpObj docx pObj = docx pObjpObj docx pObj = docx // We can even add images:pObj // Let's generate the Word document into a file: let out = fs out // Async call to generate the output file:docx
Where to go from here?
- For more information please refer to the full documentation.
- For some examples please click here.
Microsoft Excel basic usage example:
const officegen = const fs = // Create an empty Excel object:let xlsx = // Officegen calling this function after finishing to generate the xlsx document:xlsx // Officegen calling this function to report errors:xlsx let sheet = xlsxsheetname = 'Officegen Excel' // Add data using setCell: sheetsheetsheetsheet // The direct option - two-dimensional array: sheetdata0 = sheetdata00 = 1sheetdata1 = sheetdata13 = 'some'sheetdata14 = 'data'sheetdata15 = 'goes'sheetdata16 = 'here'sheetdata2 = sheetdata25 = 'more text'sheetdata26 = 900sheetdata6 = sheetdata62 = 1972 // Let's generate the Excel document into a file: let out = fs out // Async call to generate the output file:xlsx
Where to go from here?
- For more information please refer to the full documentation.
- For some examples please click here.
Support:
Examples:
- make_pptx.js - Example how to create PowerPoint 2007 presentation and save it into file.
- make_xlsx.js - Example how to create Excel 2007 sheet and save it into file.
- make_docx.js - Example how to create Word 2007 document and save it into file.
- pptx_server.js - Example HTTP server that generating a PowerPoint file with your name without using files on the server side.
The official officegen Google Group:
The officegen Slack team:
Plans for the next release:
☕️ The source code:
The project structure:
- office/index.js - The main file.
- office/lib/ - All the sources should be here.
- basicgen.js - The generic engine to build many type of document files. This module providing the basicgen plugins interface for all the document generator. Any document generator MUST use this plugins API.
- docplug.js - The document generator plugins interface - optional engine to create plugins API for each document generator.
- msofficegen.js - A template basicgen plugin to extend the default basicgen module with the common Microsoft Office stuff. All the Microsoft Office based document generators in this project are using this template plugin.
- genpptx.js - A document generator (basicgen plugin) to create a PPTX/PPSX document.
- genxlsx.js - A document generator (basicgen plugin) to create a XLSX document.
- gendocx.js - A document generator (basicgen plugin) to create a DOCX document.
- pptxplg-*.js - docplug based plugins for genpptx.js ONLY to implement Powerpoint based features.
- docxplg-*.js - docplug based plugins for genpptx.js ONLY to implement Word based features.
- xlsxplg-*.js - docplug based plugins for genpptx.js ONLY to implement Excel based features.
- officegen/test/ - All the unit tests.
- Gruntfile.js - Grunt scripts.
Code documentations:
To create the jsdoc documentation:
grunt jsdoc
External dependencies:
This project is using the following awesome libraries/utilities/services:
- archiver
- jszip
- lodash
- xmlbuilder
How to add new features:
The easiest way to add new features is by using the officegen internal plugins system.
Credit:
- Created by Ziv Barber in 2013.
- For creating zip streams i'm using 'archiver' by cmilhench, dbrockman, paulj originally inspired by Antoine van Wel's zipstream.
Contributors:
This project exists thanks to all the people who contribute.
Backers:
Thank you to all our backers! 🙏 [Become a backer]
Sponsors:
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]