Workbooks, sheets, rows, and cells map directly to Go structs and maps.
.xlsx library for Go.
Read, write, and recalculate .xlsx workbooks in Go. Open existing files, create new ones, set values and formulas, and save the result back to disk.
Add the module to a Go project and start working with workbooks, sheets, cells, and formulas.
go get github.com/jpoz/werkbook package main import "github.com/jpoz/werkbook" func main() { f := werkbook.New() s := f.Sheet("Summary") s.SetValue("A1", "Revenue") s.SetValue("B1", 583200) s.SetFormula("B2", "B1*0.12") f.Recalculate() f.SaveAs("report.xlsx") }
Sparse workbook storage and dependency tracking.
The workbook model stores only the sheets, rows, and cells you touch. Formula dependencies are tracked separately so recalculation can follow the affected cells.
Formula references are stored in a dependency graph so the engine can find which formulas need recalculation after a change.
Writes mark dependent formulas dirty, and values can be resolved lazily or through Recalculate().
dependsOn map[QualifiedCell]map[QualifiedCell]bool
dependents map[QualifiedCell]map[QualifiedCell]bool
rangeSubs []rangeSub
}
Read, write, and recalculate .xlsx files.
Open existing workbooks, create new ones, set cell values and formulas, evaluate results, and write OOXML files from Go.
Built-in formula engine
Formulas are lexed, parsed, compiled, dependency-sorted, and evaluated in Go. The project currently includes 198 built-in functions.
Sparse workbook storage
Rows and cells are stored as maps, so a workbook with data in A1 and Z10000 does not allocate the whole rectangle between them.
cells["Z10000"] = 42
Typed cell values
Numbers, strings, booleans, errors, and empty cells keep their type in the workbook model and formula engine.
OOXML read and write
Open existing .xlsx files, change sheets and cells, and write them back without Excel or another spreadsheet runtime.
The API follows spreadsheet concepts
The main types are workbooks, sheets, rows, cells, formulas, and file operations.
f := werkbook.New() s := f.Sheet("Summary") s.SetValue("A1", "Revenue") s.SetValue("B1", 583200) s.SetFormula("B2", "B1*0.12") f.SaveAs("report.xlsx")
f, _ := werkbook.Open("report.xlsx") s := f.Sheet("Summary") v, _ := s.GetValue("B2") fmt.Println(v.Raw())
Formula recalculation is explicit
Formulas are parsed, compiled, dependency-ordered, and then evaluated when you recalculate a workbook.
parser
compiler
dependency sort
evaluator
Cell values stay typed
The library keeps spreadsheet value types visible in code instead of flattening everything to strings.
Zero external dependencies
No CGo, no system packages, and no spreadsheet runtime. It stays inside a normal Go build.
require (
// none
)
Open and update existing workbooks
Load an existing .xlsx file, update values or formulas, and write it back through OOXML ZIP/XML serialization.
.xlsxCreate a workbook in three steps.
Install the module, set values and formulas, then recalculate and save the workbook as .xlsx.
Install the module
Add the package to an existing project with one command.
go get github.com/jpoz/werkbook Set values and formulas
Use workbook, sheet, and cell methods directly in Go.
Recalculate and save
Trigger formula evaluation, then write a real .xlsx file back to disk.
package main import "github.com/jpoz/werkbook" func main() { f := werkbook.New() s := f.Sheet("Sheet1") s.SetValue("A1", "Hello") s.SetFormula("B1", "LEN(A1)") f.Recalculate() f.SaveAs("output.xlsx") }
Docs, API reference, and examples.
Start with installation, then move to the API, examples, or the CLI if you want command-line access.
go get github.com/jpoz/werkbook