Handlebars Exporter is a Google Sheets addon to provide a highly configurable export tool for your sheets. It lets you configure Handlebars templates and export for your spreadsheet. The generated file will be located in the same folder with the name you specify.

It lets you export in virtually any text-based format, including:

  • Custom XML
  • JSON
  • HTML

Prerequisites

You should be familiar with Handlebars templating, as the configure page requires it. Then just install the addon, and you are ready to go.

Getting started

After installing, open the Configure Templates popup, as seen below:

Configure Templates

You will see 3 sections, one for each configurable template:

  • The name of the file
  • The contents
  • And the MIME type

On the right, there is a live preview for each section; you can instantly see what the results will be.

Configure Templates Dialog

Sample templates are already filled in, so you can see a simple CSV export. It covers some of the basics, like using the variables, loops, and conditions. It should be a great starting point.

Configure them as you see fit, click Save, then select Export from the menu. If all goes well, you will see a dialog about a successful export.

Export Menu Item

Variables

The following variables are defined:

  • spredsheetName: Exactly what you think it is
  • numSheets: The number of sheets in the spreadsheet
  • sheetNames: The names of the sheets in an array
  • sheetContents: The contents of each sheets, defined in a 2-dimensional array
  • activeSheetIndex: The index of the currently selected sheet
  • values: The values of the selected sheet in a 2-dimensional array
  • sheetName: The name of the selected sheet

You can use every variable in each of the sections.

Helpers

Along with the default Handlebars helpers, you can also use the ones listed in this repository.

Final notes

The export isn’t run automatically; if you change anything in your sheets, make sure to run it again.

Also, the previews display all errors during the conversion; it shouldn’t be hard to find typos.

In case of any issues not mentioned in this document, please let me know it. I hope you find this addon useful.