Spreadsheet
A workbook holds sheets, a sheet holds rows, and a row holds cells. You get each level from the one above, and cells are addressed within their row rather than by absolute coordinates:
ss := spreadsheet.New()
sheet := ss.AddSheet()
row := sheet.AddRow()
row.AddCell().SetString("Hello")Formatting lives in shared cell styles on the workbook rather than on individual cells, so a large sheet holds a few styles and many references to them. A formula’s text and its computed value are stored separately, so writing a formula calculates nothing until something evaluates it.
Validation is the other habit worth picking up. Validate() catches structural
problems before you write the file, which is a great deal easier than working
out why Excel is refusing to open the result.
Build a workbook
| Section | Covers |
|---|---|
| Simple Spreadsheet | The shortest complete program. Start here. |
| Complex Spreadsheet | A worked example combining several features. |
| Cells | Borders, shading, number formats, merging, rotation, comments. |
| Rows and Columns | Inserting, removing, freezing, sorting and filtering. |
| Formulas | Setting, evaluating, flattening, and named references. |
| Charts | Every chart type, one guide each. |
| Images | Placing and extracting pictures. |
| Format as Table | Turning a range into a styled Excel table. |
Read and output
| Section | Covers |
|---|---|
| Text Extraction | Reading cell content back out. |
| Validate a Workbook | Catching structural problems before writing. |
| Convert to PDF | Rendering sheets to PDF. |
Last updated on