Documentation
¶
Overview ¶
Package excel builds spreadsheet workbooks from a declarative description of columns and rows, with no knowledge of any domain type.
Index ¶
- Constants
- Variables
- func Build(spec Spec) ([]byte, error)
- func Date(v *time.Time) string
- func Filename(slug string, at time.Time) string
- func FilenameWithExt(slug string, at time.Time, ext string) string
- func JoinNames(names []string) string
- func Str(v *string) string
- type ColumnSpec
- type Row
- type Sheet
- type Spec
Constants ¶
const ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
identifies the workbooks this package produces
Variables ¶
var ErrNoSheets = errors.New("excel: a workbook needs at least one sheet")
reports a spec that would produce a file Excel refuses to open
Functions ¶
func Filename ¶
names an export's file from its resource slug, e.g. "unit_groups_export_07-30-2026.xlsx". One separator throughout, so the name survives a URL path without escaping.
func FilenameWithExt ¶
FilenameWithExt names an export's file in a given format. The extension is part of the object key, and the browser takes the download's name from that key — so an export that is not a spreadsheet must say so here or it is saved under an extension that will not open.
Types ¶
type ColumnSpec ¶
type ColumnSpec struct {
Header string
Key string
Width float64
// NumFmt is an Excel custom number format applied to the column's data cells.
NumFmt string
// Note is a hover comment on the header cell.
Note string
}
describes one column. Rows address it by Key; nothing outside this package computes a column letter, which is what stops the two diverging.
type Sheet ¶
type Sheet struct {
Name string
Columns []ColumnSpec
Rows []Row
}
describes one worksheet