{"id":13527337,"url":"https://github.com/Ziv-Barber/officegen","last_synced_at":"2025-04-01T09:31:24.423Z","repository":{"id":8973959,"uuid":"10717384","full_name":"Ziv-Barber/officegen","owner":"Ziv-Barber","description":"Standalone Office Open XML files (Microsoft Office 2007 and later) generator for Word (docx), PowerPoint (pptx) and Excell (xlsx) in javascript. The output is a stream.","archived":false,"fork":false,"pushed_at":"2024-04-30T10:40:22.000Z","size":4372,"stargazers_count":2651,"open_issues_count":199,"forks_count":470,"subscribers_count":88,"default_branch":"master","last_synced_at":"2024-10-29T21:14:19.665Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ziv-Barber.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-06-16T07:58:57.000Z","updated_at":"2024-10-29T06:23:50.000Z","dependencies_parsed_at":"2024-11-05T22:29:47.646Z","dependency_job_id":"373f7bf4-14ee-4442-b202-95ee631244ec","html_url":"https://github.com/Ziv-Barber/officegen","commit_stats":{"total_commits":351,"total_committers":58,"mean_commits":6.051724137931035,"dds":0.4700854700854701,"last_synced_commit":"87dd5501968501555ea3bee60043affc9f67c1fa"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ziv-Barber%2Fofficegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ziv-Barber%2Fofficegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ziv-Barber%2Fofficegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ziv-Barber%2Fofficegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ziv-Barber","download_url":"https://codeload.github.com/Ziv-Barber/officegen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246093179,"owners_count":20722403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T06:01:45.943Z","updated_at":"2025-04-01T09:31:22.981Z","avatar_url":"https://github.com/Ziv-Barber.png","language":"JavaScript","funding_links":["https://opencollective.com/officegen"],"categories":["Repository","JavaScript"],"sub_categories":["Office"],"readme":"# officegen\n\nCreating Office Open XML files (Word, Excel and Powerpoint) for Microsoft Office 2007 and later without external tools, just pure Javascript.\n*officegen* should work on any environment that supports Node.js including Linux, OSX and Windows.\n*officegen* also supporting PowerPoint *native* charts objects with embedded data.\n\n[![npm version](https://badge.fury.io/js/officegen.svg)](https://badge.fury.io/js/officegen)\n[![dependencies](https://david-dm.org/Ziv-Barber/officegen.svg?style\u0026#x3D;flat-square)](https://david-dm.org/Ziv-Barber/officegen)\n[![devDependencies](https://david-dm.org/Ziv-Barber/officegen/dev-status.svg?style\u0026#x3D;flat-square)](https://david-dm.org/Ziv-Barber/officegen#info\u0026#x3D;devDependencies)\n[![Build Status](https://travis-ci.org/Ziv-Barber/officegen.png?branch=master)](https://travis-ci.org/Ziv-Barber/officegen)\n[![Join the chat at https://gitter.im/officegen/Lobby](https://badges.gitter.im/officegen/Lobby.svg)](https://gitter.im/officegen/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge) \n[![Backers on Open Collective](https://opencollective.com/officegen/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/officegen/sponsors/badge.svg)](#sponsors) \n\n![Officegen logo](logo.png)\n![Microsoft Office logo](logo_office.png)\n\n- [Getting Started](#getstart)\n  - [Installation](#install)\n  - [Getting Started with PowerPoint](#getspptx)\n  - [Getting Started with Word](#getsdocx)\n  - [Getting Started with Excel](#getsxlsx)\n- [Full documentation](manual/README.md)\n- [Support](#support)\n- [The source code](#code)\n- [Credit](#credit)\n- [Contributors](#contributors)\n- [Backers](#backers)\n- [Sponsors](#sponsors)\n\n## Contributors:\n\nThis project exists thanks to all the people who contribute.\n\n\u003ca name=\"getstart\"\u003e\u003c/a\u003e\n## Getting Started: ##\n\n![Microsoft Powerpoint logo](logo_powerpoint.png)\n![Microsoft Word logo](logo_word.png)\n![Microsoft Excel logo](logo_excel.png)\n\n### Officegen features overview:\n\n- Generating Microsoft PowerPoint document (.pptx file):\n  - Create PowerPoint document with one or more slides.\n  - Support both PPT and PPS.\n  - Can create native charts.\n  - Add text blocks.\n  - Add images.\n  - Can declare fonts, alignment, colors and background.\n  - You can rotate objects.\n  - Support shapes: Ellipse, Rectangle, Line, Arrows, etc.\n  - Support hidden slides.\n  - Support automatic fields like date, time and current slide number.\n  - Support speaker notes.\n  - Support slide layouts.\n- Generating Microsoft Word document (.docx file):\n  - Create Word document.\n  - You can add one or more paragraphs to the document and you can set the fonts, colors, alignment, etc.\n  - You can add images.\n  - Support header and footer.\n  - Support bookmarks and hyperlinks.\n- Generating Microsoft Excel document (.xlsx file):\n  - Create Excel document with one or more sheets. Supporting cells with either numbers or strings.\n\n\u003ca name=\"install\"\u003e\u003c/a\u003e\n### Installation:\n\n```bash\n$ npm install officegen\n```\n\n\u003ca name=\"getspptx\"\u003e\u003c/a\u003e\n### Microsoft PowerPoint basic usage example:\n\n```js\nconst officegen = require('officegen')\nconst fs = require('fs')\n\n// Create an empty PowerPoint object:\nlet pptx = officegen('pptx')\n\n// Let's add a title slide:\n\nlet slide = pptx.makeTitleSlide('Officegen', 'Example to a PowerPoint document')\n\n// Pie chart slide example:\n\nslide = pptx.makeNewSlide()\nslide.name = 'Pie Chart slide'\nslide.back = 'ffff00'\nslide.addChart(\n  {\n    title: 'My production',\n    renderType: 'pie',\n    data:\n\t[\n      {\n        name: 'Oil',\n        labels: ['Czech Republic', 'Ireland', 'Germany', 'Australia', 'Austria', 'UK', 'Belgium'],\n        values: [301, 201, 165, 139, 128,  99, 60],\n        colors: ['ff0000', '00ff00', '0000ff', 'ffff00', 'ff00ff', '00ffff', '000000']\n      }\n    ]\n  }\n)\n\n// Let's generate the PowerPoint document into a file:\n\nreturn new Promise((resolve, reject) =\u003e {\n  let out = fs.createWriteStream('example.pptx')\n\n  // This one catch only the officegen errors:\n  pptx.on('error', function(err) {\n    reject(err)\n  })\n\n  // Catch fs errors:\n  out.on('error', function(err) {\n    reject(err)\n  })\n\n  // End event after creating the PowerPoint file:\n  out.on('close', function() {\n    resolve()\n  })\n\n  // This async method is working like a pipe - it'll generate the pptx data and put it into the output stream:\n  pptx.generate(out)\n})\n```\n\nSince that officegen is using node.js events you can also create a document directly into a http respons stream:\n\n```\nconst officegen = require('officegen')\nconst http = require('http')\n\n/**\n * This is a simple web server that response with a PowerPoint document.\n */\nhttp.createServer(function(req, res) {\n  // We'll send a generated on the fly PowerPoint document without using files:\n  if (req.url == '/') {\n    // Create an empty PowerPoint object:\n    let pptx = officegen('pptx')\n\n    // Let's create a new slide:\n    var slide = pptx.makeNewSlide()\n\n    slide.name = 'Hello World'\n\n    // Change the background color:\n    slide.back = '000000'\n\n    // Declare the default color to use on this slide:\n    slide.color = 'ffffff'\n\n    // Basic way to add text string:\n    slide.addText('Created on the fly using a http server!')\n\n    //\n    // Let's generate the PowerPoint document directly into the response stream:\n    //\n\n    response.writeHead(200, {\n      'Content-Type':\n        'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n      'Content-disposition': 'attachment filename=out.pptx'\n    })\n\n\t// Content types related to Office documents:\n    // .xlsx   application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\n    // .xltx   application/vnd.openxmlformats-officedocument.spreadsheetml.template\n    // .potx   application/vnd.openxmlformats-officedocument.presentationml.template\n    // .ppsx   application/vnd.openxmlformats-officedocument.presentationml.slideshow\n    // .pptx   application/vnd.openxmlformats-officedocument.presentationml.presentation\n    // .sldx   application/vnd.openxmlformats-officedocument.presentationml.slide\n    // .docx   application/vnd.openxmlformats-officedocument.wordprocessingml.document\n    // .dotx   application/vnd.openxmlformats-officedocument.wordprocessingml.template\n    // .xlam   application/vnd.ms-excel.addin.macroEnabled.12\n    // .xlsb   application/vnd.ms-excel.sheet.binary.macroEnabled.12\n\n    // This one catch only the officegen errors:\n    pptx.on('error', function(err) {\n      res.end(err)\n    })\n\n    // Catch response errors:\n    res.on('error', function(err) {\n      res.end(err)\n    })\n\n    // End event after sending the PowerPoint data:\n    res.on('finish', function() {\n      res.end()\n    })\n\n    // This async method is working like a pipe - it'll generate the pptx data and pass it directly into the output stream:\n    pptx.generate(res)\n  } else {\n    res.end('Invalid Request!')\n  } // Endif.\n}).listen(3000)\n```\n\n### Where to go from here?\n\n- For more information please refer to the [full documentation](manual/README.md).\n- For some examples please [click here](#examples).\n\n\u003ca name=\"getspptx\"\u003e\u003c/a\u003e\n### Microsoft Word basic usage example:\n\n```js\nconst officegen = require('officegen')\nconst fs = require('fs')\n\n// Create an empty Word object:\nlet docx = officegen('docx')\n\n// Officegen calling this function after finishing to generate the docx document:\ndocx.on('finalize', function(written) {\n  console.log(\n    'Finish to create a Microsoft Word document.'\n  )\n})\n\n// Officegen calling this function to report errors:\ndocx.on('error', function(err) {\n  console.log(err)\n})\n\n// Create a new paragraph:\nlet pObj = docx.createP()\n\npObj.addText('Simple')\npObj.addText(' with color', { color: '000088' })\npObj.addText(' and back color.', { color: '00ffff', back: '000088' })\n\npObj = docx.createP()\n\npObj.addText('Since ')\npObj.addText('officegen 0.2.12', {\n  back: '00ffff',\n  shdType: 'pct12',\n  shdColor: 'ff0000'\n}) // Use pattern in the background.\npObj.addText(' you can do ')\npObj.addText('more cool ', { highlight: true }) // Highlight!\npObj.addText('stuff!', { highlight: 'darkGreen' }) // Different highlight color.\n\npObj = docx.createP()\n\npObj.addText('Even add ')\npObj.addText('external link', { link: 'https://github.com' })\npObj.addText('!')\n\npObj = docx.createP()\n\npObj.addText('Bold + underline', { bold: true, underline: true })\n\npObj = docx.createP({ align: 'center' })\n\npObj.addText('Center this text', {\n  border: 'dotted',\n  borderSize: 12,\n  borderColor: '88CCFF'\n})\n\npObj = docx.createP()\npObj.options.align = 'right'\n\npObj.addText('Align this text to the right.')\n\npObj = docx.createP()\n\npObj.addText('Those two lines are in the same paragraph,')\npObj.addLineBreak()\npObj.addText('but they are separated by a line break.')\n\ndocx.putPageBreak()\n\npObj = docx.createP()\n\npObj.addText('Fonts face only.', { font_face: 'Arial' })\npObj.addText(' Fonts face and size.', { font_face: 'Arial', font_size: 40 })\n\ndocx.putPageBreak()\n\npObj = docx.createP()\n\n// We can even add images:\npObj.addImage('some-image.png')\n\n// Let's generate the Word document into a file:\n\nlet out = fs.createWriteStream('example.docx')\n\nout.on('error', function(err) {\n  console.log(err)\n})\n\n// Async call to generate the output file:\ndocx.generate(out)\n```\n\n### Where to go from here?\n\n- For more information please refer to the [full documentation](manual/README.md).\n- For some examples please [click here](#examples).\n\n\u003ca name=\"getspptx\"\u003e\u003c/a\u003e\n### Microsoft Excel basic usage example:\n\n```js\nconst officegen = require('officegen')\nconst fs = require('fs')\n\n// Create an empty Excel object:\nlet xlsx = officegen('xlsx')\n\n// Officegen calling this function after finishing to generate the xlsx document:\nxlsx.on('finalize', function(written) {\n  console.log(\n    'Finish to create a Microsoft Excel document.'\n  )\n})\n\n// Officegen calling this function to report errors:\nxlsx.on('error', function(err) {\n  console.log(err)\n})\n\nlet sheet = xlsx.makeNewSheet()\nsheet.name = 'Officegen Excel'\n\n// Add data using setCell:\n\nsheet.setCell('E7', 42)\nsheet.setCell('I1', -3)\nsheet.setCell('I2', 3.141592653589)\nsheet.setCell('G102', 'Hello World!')\n\n// The direct option - two-dimensional array:\n\nsheet.data[0] = []\nsheet.data[0][0] = 1\nsheet.data[1] = []\nsheet.data[1][3] = 'some'\nsheet.data[1][4] = 'data'\nsheet.data[1][5] = 'goes'\nsheet.data[1][6] = 'here'\nsheet.data[2] = []\nsheet.data[2][5] = 'more text'\nsheet.data[2][6] = 900\nsheet.data[6] = []\nsheet.data[6][2] = 1972\n\n// Let's generate the Excel document into a file:\n\nlet out = fs.createWriteStream('example.xlsx')\n\nout.on('error', function(err) {\n  console.log(err)\n})\n\n// Async call to generate the output file:\nxlsx.generate(out)\n```\n\n### Where to go from here?\n\n- For more information please refer to the [full documentation](manual/README.md).\n- For some examples please [click here](#examples).\n\n\u003ca name=\"support\"\u003e\u003c/a\u003e\n## Support:\n\n\u003ca name=\"examples\"\u003e\u003c/a\u003e\n### Examples:\n\n- [make_pptx.js](examples/make_pptx.js) - Example how to create PowerPoint 2007 presentation and save it into file.\n- [make_xlsx.js](examples/make_xlsx.js) - Example how to create Excel 2007 sheet and save it into file.\n- [make_docx.js](examples/make_docx.js) - Example how to create Word 2007 document and save it into file.\n- [pptx_server.js](examples/pptx_server.js) - Example HTTP server that generating a PowerPoint file with your name without using files on the server side.\n\n### The official officegen Google Group:\n\n[officegen Google Group](https://groups.google.com/forum/?fromgroups#!forum/node-officegen)\n\n### The officegen Slack team:\n\n[Slack](https://zivbarber.slack.com/messages/officegen/)\n\n### Plans for the next release:\n\n[Trello](\u003chttps://trello.com/b/dkaiSGir/officegen-make-office-documents-in-javascript\u003e)\n\n\u003ca name=\"code\"\u003e\u003c/a\u003e\n## :coffee: The source code:\n\n### The project structure:\n\n- office/index.js - The main file.\n- office/lib/ - All the sources should be here.\n  - 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.\n  - docplug.js - The document generator plugins interface - optional engine to create plugins API for each document generator.\n  - 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.\n  - genpptx.js - A document generator (basicgen plugin) to create a PPTX/PPSX document.\n  - genxlsx.js - A document generator (basicgen plugin) to create a XLSX document.\n  - gendocx.js - A document generator (basicgen plugin) to create a DOCX document.\n  - pptxplg-*.js - docplug based plugins for genpptx.js ONLY to implement Powerpoint based features.\n  - docxplg-*.js - docplug based plugins for genpptx.js ONLY to implement Word based features.\n  - xlsxplg-*.js - docplug based plugins for genpptx.js ONLY to implement Excel based features.\n- officegen/test/ - All the unit tests.\n- Gruntfile.js - Grunt scripts.\n\n### Code documentations:\n\nTo create the jsdoc documentation:\n\n```bash\ngrunt jsdoc\n```\n\n### External dependencies:\n\nThis project is using the following awesome libraries/utilities/services:\n\n- archiver\n- jszip\n- lodash\n- xmlbuilder\n\n### How to add new features:\n\nThe easiest way to add new features is by using the officegen internal [plugins system](manual/advanced/plugins/README.md).\n\n\u003ca name=\"credits\"\u003e\u003c/a\u003e\n## Credit:\n\n- Created by Ziv Barber in 2013.\n- For creating zip streams i'm using 'archiver' by cmilhench, dbrockman, paulj originally inspired by Antoine van Wel's zipstream.\n\n\u003ca name=\"contributors\"\u003e\u003c/a\u003e\n## Contributors:\n\nThis project exists thanks to all the people who contribute. \n\n\u003ca href=\"https://github.com/Ziv-Barber/officegen/graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/officegen/contributors.svg?width=890\u0026button=false\" /\u003e\u003c/a\u003e\n\n\u003ca name=\"backers\"\u003e\u003c/a\u003e\n## Backers:\n\nThank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/officegen#backer)]\n\n\u003ca href=\"https://opencollective.com/officegen#backers\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/officegen/backers.svg?width=890\"\u003e\u003c/a\u003e\n\n\u003ca name=\"sponsors\"\u003e\u003c/a\u003e\n## Sponsors:\n\nSupport this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/officegen#sponsor)]\n\n\u003ca href=\"https://opencollective.com/officegen/sponsor/0/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/officegen/sponsor/0/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/officegen/sponsor/1/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/officegen/sponsor/1/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/officegen/sponsor/2/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/officegen/sponsor/2/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/officegen/sponsor/3/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/officegen/sponsor/3/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/officegen/sponsor/4/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/officegen/sponsor/4/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/officegen/sponsor/5/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/officegen/sponsor/5/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/officegen/sponsor/6/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/officegen/sponsor/6/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/officegen/sponsor/7/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/officegen/sponsor/7/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/officegen/sponsor/8/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/officegen/sponsor/8/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/officegen/sponsor/9/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/officegen/sponsor/9/avatar.svg\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZiv-Barber%2Fofficegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FZiv-Barber%2Fofficegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZiv-Barber%2Fofficegen/lists"}