Aspose.Cells FOSS for Go is a free, open-source library for working with Excel spreadsheet files in Go applications. Install it with go get github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Go/v26 and start creating workbooks, reading and writing cells, applying styles, adding data validation, and exporting to CSV, without requiring Microsoft Excel or any Office dependency.
The library exposes a small, idiomatic Go API built around Workbook, Worksheet, Cells, and Cell. Access cells through the Cells() collection with Get/Set/Remove, group formatting into reusable Style objects built from Font, Fill, Alignment, and Border, and build structured Table ranges with a header row and named table style. A dedicated StreamingReader reads .xlsx workbooks row by row via a callback, so large files can be processed without loading the entire sheet into memory.
go.mod declares no external dependencies — the library is built entirely on the Go standard library. It is MIT-licensed, hosted on GitHub, and installs with a single go get command; no cgo, no native Office libraries, and no system packages to configure. For the enterprise product family, see Aspose.Cells — Enterprise Product Family.
Cells().Get(ref) / Cells().Set(ref, value).Cell.SetFormula/GetFormula store a formula string in the cell — evaluated by Excel or LibreOffice on open, not by the library at save time.Workbook.ExportToCSV/ImportFromCSV and Worksheet.ToCSV/FromCSV convert between XLSX and CSV.StreamingReader.ProcessRows streams a worksheet row by row via a callback, for large-file processing without loading the whole sheet into memory.Workbook.SetPassword/VerifyPassword protect and check workbook passwords.StreamingReader instead of loading them fully into memory.Font (name, size, bold, italic, color), Fill (type, color), Alignment (horizontal, vertical, wrap text), and Border (top/bottom/left/right, color) into a reusable Style, applied with Cell.SetStyle.Worksheet.AddDataValidation attaches list and whole-number range validation rules, each with a custom error title, message, and error style.Worksheet.AddTable/GetTable create a structured Table range with an optional header row and a named table style.Worksheet.AddPicture embeds an image Picture with SetAnchor(row, col) positioning.Aspose.Cells FOSS for Go installs with a single go get github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Go/v26 command. go.mod has no require entries — there are no external dependencies to vet or vendor.
The API surface is intentionally compact: Workbook, Worksheet, Cells, Cell, Style, and a handful of supporting types cover spreadsheet creation, styling, validation, and CSV/streaming I/O. The codebase is MIT-licensed and hosted on GitHub.
Install with go get, create a Workbook, access the first Worksheet, and write values directly to cells through the Cells() collection before saving.
go get github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Go/v26
func main() {
wb := cells_foss.NewWorkbook()
ws := wb.Worksheets[0]
ws.Cells().Set("A1", "Hello")
ws.Cells().Set("B1", "World")
ws.Cells().Set("A2", "Answer")
ws.Cells().Set("B2", 42)
outPath := "outputfiles/basic.xlsx"
if err := wb.Save(outPath); err != nil {
fmt.Printf("Error saving workbook: %v\n", err)
return
}
fmt.Printf("Workbook saved to %s\n", outPath)
}
Attach a list-type validation (a dropdown of allowed values) and a whole-number range validation to two different columns, each with its own error title and message.
func main() {
wb := cells_foss.NewWorkbook()
ws := wb.Worksheets[0]
ws.Cells().Set("A1", "Fruit")
ws.Cells().Set("A2", "Apple")
ws.Cells().Set("A3", "Banana")
dv := &cells_foss.DataValidation{
Type: cells_foss.DataValidationTypeList,
Formula1: `"Apple,Banana,Cherry,Dragonfruit"`,
AllowBlank: true,
ShowErrorMessage: true,
ErrorTitle: "Invalid Fruit",
ErrorMessage: "Please pick a fruit from the list.",
ErrorStyle: cells_foss.ErrorStyleStop,
}
if err := ws.AddDataValidation("A2:A10", dv); err != nil {
fmt.Printf("Error: %v\n", err)
return
}
dv2 := &cells_foss.DataValidation{
Type: cells_foss.DataValidationTypeWhole,
Formula1: "1",
Formula2: "100",
ShowErrorMessage: true,
ErrorTitle: "Invalid Value",
ErrorMessage: "Enter a whole number between 1 and 100.",
ErrorStyle: cells_foss.ErrorStyleWarning,
}
ws.Cells().Set("B1", "Score (1-100)")
ws.AddDataValidation("B2:B10", dv2)
outPath := "outputfiles/data_validation.xlsx"
if err := wb.Save(outPath); err != nil {
fmt.Printf("Error saving workbook: %v\n", err)
return
}
fmt.Printf("Workbook saved to %s\n", outPath)
}
StreamingReader reads a worksheet one row at a time through a callback, so a multi-thousand-row workbook never has to be fully loaded into memory.
func main() {
genPath := "outputfiles/streaming_data.xlsx"
sr := cells_foss.NewStreamingReader(genPath)
rowCount := 0
var totalScore float64
err := sr.ProcessRows("Sheet1", func(rowIdx int, cells map[string]string) error {
rowCount++
if rowIdx == 1 {
fmt.Printf(" Header: %v\n", cells)
return nil
}
if score, ok := cells["C"+fmt.Sprint(rowIdx)]; ok {
var s float64
fmt.Sscanf(score, "%f", &s)
totalScore += s
}
return nil
})
if err != nil {
fmt.Fprintf(os.Stderr, "Error streaming: %v\n", err)
os.Exit(1)
}
fmt.Printf("Streamed %d rows (header + %d data rows)\n", rowCount, rowCount-1)
}
Aspose.Cells FOSS for Go is released under the MIT License, which permits commercial and open-source use.
Yes. The MIT License permits commercial use with no obligation to disclose your own source code, as long as the original copyright notice is retained.
Add it as a Go module dependency with go get github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Go/v26. Requires Go 1.24 or later.
No. go.mod declares no require entries — the library is built entirely on the Go standard library.
Yes. StreamingReader.ProcessRows reads a worksheet row by row through a callback, avoiding a full in-memory load.