{"id":15138792,"url":"https://github.com/zhangyu836/node-xlsx-template","last_synced_at":"2025-08-23T01:06:23.392Z","repository":{"id":57401771,"uuid":"212946705","full_name":"zhangyu836/node-xlsx-template","owner":"zhangyu836","description":"A node module to generate xlsx files from a xlsx template","archived":false,"fork":false,"pushed_at":"2022-05-06T07:18:12.000Z","size":122,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-20T01:30:41.650Z","etag":null,"topics":["excel","exceljs","jinja","nunjucks","spreadsheet","spreadsheet-manipulation","template","workbook","workbook-writer"],"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/zhangyu836.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-05T05:04:11.000Z","updated_at":"2025-06-11T13:24:38.000Z","dependencies_parsed_at":"2022-09-15T18:41:01.560Z","dependency_job_id":null,"html_url":"https://github.com/zhangyu836/node-xlsx-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zhangyu836/node-xlsx-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyu836%2Fnode-xlsx-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyu836%2Fnode-xlsx-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyu836%2Fnode-xlsx-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyu836%2Fnode-xlsx-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhangyu836","download_url":"https://codeload.github.com/zhangyu836/node-xlsx-template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyu836%2Fnode-xlsx-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271727512,"owners_count":24810561,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["excel","exceljs","jinja","nunjucks","spreadsheet","spreadsheet-manipulation","template","workbook","workbook-writer"],"created_at":"2024-09-26T07:44:37.375Z","updated_at":"2025-08-23T01:06:23.362Z","avatar_url":"https://github.com/zhangyu836.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\r\n# xltpl ( node-xlsx-template )\r\nA node module to generate .xlsx files from a .xlsx template.\r\n\r\n## How it works\r\n\r\nWhen xltpl reads a xlsx file, it creates a tree for each worksheet.  \r\nAnd, each tree is translated to a nunjucks(jinja2) template with custom tags.  \r\nWhen the template is rendered, nunjucks extensions of cumtom tags call corresponding tree nodes to write the xlsx file.\r\n\r\n## How to install\r\n\r\n```shell\r\nnpm install xltpl\r\n```\r\n\r\n## How to use\r\n\r\n*   To use xltpl, you need to be familiar with the [syntax of nunjucks template](https://mozilla.github.io/nunjucks/templating.html).\r\n*   Get a pre-written xls/x file as the template.\r\n*   Insert variables in the cells, such as : \r\n\r\n```jinja2\r\n{{name}}\r\n```\r\n\r\n*   Insert control statements in the cells :\r\n\r\n```jinja2\r\n{%- for row in rows %}\r\n{% set outer_loop = loop %}{% for row in rows %}\r\nCell text\r\n{{outer_loop.index}}{{loop.index}}\r\n{%+ endfor%}{%+ endfor%}\r\n```\r\n\r\n*   Run the code\r\n```javascript\r\nlet BookWriter = require('xltpl');\r\nfunction run() {\r\n    let writer = new BookWriter();\r\n    let p = writer.readFile('template.xlsx');\r\n    p.then(async function () {\r\n        let payloads = await getPayloads();\r\n        writer.renderSheets(payloads);\r\n        await writer.save('result.xlsx');\r\n    })\r\n}\r\nrun();\r\n```\r\nSee [examples](https://github.com/zhangyu836/node-xlsx-template/tree/master/examples). \r\n\r\n## CodeSandbox examples\r\n* [browser](https://codesandbox.io/s/xlsx-export-with-exceljs-and-xltpl-58j9g6)\r\n* [node](https://codesandbox.io/s/exceljs-template-with-xltpl-4w58xo)\r\n\r\n## Supported\r\n* MergedCell   \r\n* Non-string value for a cell (use **{{variable}}** with no leading  or trailing spaces or **{%xv variable%}** to specify a variable) \r\n* Image (use **{%img variable%}**)  \r\n* DataValidation   \r\n* AutoFilter\r\n\r\n\r\n## Related\r\n\r\n* [xltpl for python](https://github.com/zhangyu836/xltpl)\r\n* [exceljs](https://github.com/exceljs/exceljs)\r\n* [nunjucks](https://mozilla.github.io/nunjucks/)\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhangyu836%2Fnode-xlsx-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhangyu836%2Fnode-xlsx-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhangyu836%2Fnode-xlsx-template/lists"}