{"id":24502522,"url":"https://github.com/momsfriendlydevco/spreadsheet-templater","last_synced_at":"2025-07-26T09:34:53.740Z","repository":{"id":78689340,"uuid":"169009117","full_name":"MomsFriendlyDevCo/spreadsheet-templater","owner":"MomsFriendlyDevCo","description":"Simple templates markup for spreadsheets","archived":false,"fork":false,"pushed_at":"2022-03-06T22:57:51.000Z","size":86,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-18T20:20:03.595Z","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/MomsFriendlyDevCo.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,"governance":null}},"created_at":"2019-02-04T00:24:32.000Z","updated_at":"2022-03-06T22:57:54.000Z","dependencies_parsed_at":"2023-03-07T08:15:57.315Z","dependency_job_id":null,"html_url":"https://github.com/MomsFriendlyDevCo/spreadsheet-templater","commit_stats":{"total_commits":32,"total_committers":2,"mean_commits":16.0,"dds":0.21875,"last_synced_commit":"db80d5c5534aaaabc3978b7e440ca569961c0888"},"previous_names":["momsfriendlydevco/spreadsheet-handlebars"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MomsFriendlyDevCo/spreadsheet-templater","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fspreadsheet-templater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fspreadsheet-templater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fspreadsheet-templater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fspreadsheet-templater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MomsFriendlyDevCo","download_url":"https://codeload.github.com/MomsFriendlyDevCo/spreadsheet-templater/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fspreadsheet-templater/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267145730,"owners_count":24042651,"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-07-26T02:00:08.937Z","response_time":62,"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":[],"created_at":"2025-01-21T23:12:12.257Z","updated_at":"2025-07-26T09:34:53.703Z","avatar_url":"https://github.com/MomsFriendlyDevCo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Spreadsheet-Templater\n=====================\nSimple templates markup for spreadsheets (via [XLSX](https://docs.sheetjs.com)).\n\nThis plugin allows a spreadsheet to use handlebars-like notation to replace cell contents which enables an input spreadsheet to act as a template for incoming data.\n\n\n```javascript\nvar SpreadsheetTemplater = require('@momsfriendlydevco/spreadsheet-templater');\n\nnew SpreadsheetTemplater()\n\t.read('input.xlsx')\n\t.data({...})\n\t.apply()\n\t.write('output.xlsx')\n```\n\nSee the test directory for some example spreadsheets.\n\n\nLimitations\n-----------\nThere are a few restrictions with this module, mainly due to time and technical limitations:\n\n* Nested `{{#each}}` + `{{/each}}` statements are not supported\n* Due to no support for dynamic row adding, at the time of writing, in the upstream [xlsx-populate](https://github.com/dtjohnson/xlsx-populate) library this module will overwrite all rows below the `{{each}}` blocks with however many rows of data need placing - the spreadsheet contents *below* the `{{each}}` blocks will not be moved down\n\n\nDebugging\n---------\nThis module uses the [Debug NPM](https://github.com/visionmedia/debug#readme). To enable simply set the `DEBUG` environment variable to include `spreadsheet-templater`\n\n\nMarkup\n======\nThis module reads all cells in all sheets and applies simple substitutions based on a Handlebars like template based on an input data set.\n\n\nSimple substitution\n-------------------\nSimple substitution is performed by putting a [lodash compatible dotted notation](https://lodash.com/docs#get) path inside double braces.\nFor example `{{people.0.name}}` - extracts from the data object the key `people`, the first element of the array and the subkey `name`.\n\n\nRepeaters\n---------\nBasic support is provided for single level repeaters. Repeaters start (`{{#each ITERABLE}}`) in the first cell and are read horizontally until the end is encountered (`{{/each}}`).\n\nFor example assuming the following CSV spreadsheet layout:\n\n```\nName,Email,Phone,Address\n{{#each people}}{{name}},{{email}},{{phone}},\"{{address.street}}, {{address.city}}, {{address.zipcode}}{{/each}}\"\n```\n\nThe spreadsheet would be populated with all items in the `people` collection until exhausted.\n\nIf no specific data path is specified for each (i.e. `{{#each}}`) the main data object is assumed to be an array and it is used instead.\n\n\nAPI\n===\nThe module exposes a single object.\n\nThis module supports the following options:\n\n| Option                  | Type     | Default                    | Description                                                                     |\n|-------------------------|----------|----------------------------|---------------------------------------------------------------------------------|\n| `re`                    | Object   |                            | The regular expressions used when detecting markup                              |\n| `re.expression`         | RegExp   | `/{{(.+?)}}/`              | RegExp to detect a single expression replacement                                |\n| `re.repeatStart`        | RegExp   | `/{{#?\\s*each\\s+(.+?)}}/g` | How to identify the start of a repeater                                         |\n| `re.repeatEnd`          | RegExp   | `/{{\\/each.*?}}/`          | How to identify the end of a repeater                                           |\n| `repeaterSilentOnError` | Boolean  | `false`                    | Whether the module should throw when a non-array path is provided to a repeater |\n| `template`              | Object   |                            | Options to control templates                                                    |\n| `template.path`         | String   |                            | The source file to process the template from                                    |\n| `data`                  | Object   | `{}`                       | The data object used when marking up the template output                        |\n| `defaultValue`          | Any      | `''`                       | The value used when no corresponding simple dotted path can be located          |\n| `templateDetect`        | Function | See code                   | How to determine if a cell needs to be templated                                |\n| `templatePreProcess`    | Array    | `[]`                       | Array of functions that can mutate a cell template before processing            |\n| `templateSettings`      | Object   | See code                   | Settings passed to [the templating NPM](https://github.com/MomsFriendlyDevCo/template) |\n| `dateDetect`            | RegEx    | See code                   | RegEx for detecting date output before formatting                               |\n| `dateFormat`            | String   | `\"dd/mm/yyyy\"`             | The date format to use when `dateDetect` succeeds                               |\n\n\nConstructor([options])\n----------------------\nSetup the initial object with options.\n\n\nset(key, [val])\n---------------\nSet a single or multiple options (if key is an object).\nLodash array and dotted notation is supported for the key.\n\n\nread([path])\n------------\nParse the input template file.\nThis function is automatically called if constructor is given a filename when initialized.\n\n\napply([data])\n-------------\nApply the given data (or the data specified in `options.data`) to the loaded template.\n\n\ndata([data])\n-------------\nAlternate way to set template data.\n\n\njson()\n------\nConvenience function to return the workbook as a JSON object\nThis will return an object with each key as the sheet ID and a 2D array of cells\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmomsfriendlydevco%2Fspreadsheet-templater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmomsfriendlydevco%2Fspreadsheet-templater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmomsfriendlydevco%2Fspreadsheet-templater/lists"}