go-xlsx-templater icon indicating copy to clipboard operation
go-xlsx-templater copied to clipboard

Allow cells to be formatted as numbers

Open duckbrain opened this issue 4 years ago • 0 comments

Allows cells to be number formatted by prefixing the value with a # followed by a valid numeric string. In the template, the number formatting can be applied to an individual cell to have the looped rows each have that formatting when formatted as a number.

This allows users viewing the Excel file to select ranges to see a sum, create formulas that do arithmetic on cells, and much more.

Example

Template
Name Pay
{{range users}}
{{name }} #{{pay}}
{{end}}
Data
[
  {
    "name": "Alice",
    "pay": 27
  },
  {
    "name": "Bob",
    "pay": 31.5
  }
]
Reults
Name Pay
Alice $27.00
Bob $31.50

It's untested if this works with timestamps, but if not. I'd submit @ as a prefix to signify it.

duckbrain avatar Feb 29 '20 00:02 duckbrain