1. Products
  2.   Aspose.Cells
  3.   Aspose.Cells FOSS for Go

Aspose.Cells FOSS for Go

Create, modify, and export Excel spreadsheets from Go — free and open-source, zero external dependencies.

Open-Source Go Library for Excel Spreadsheets

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.

Read and Write Excel Files

  • Cell access: Read and write values with Cells().Get(ref) / Cells().Set(ref, value).
  • Formulas: Cell.SetFormula/GetFormula store a formula string in the cell — evaluated by Excel or LibreOffice on open, not by the library at save time.
  • CSV interop: Workbook.ExportToCSV/ImportFromCSV and Worksheet.ToCSV/FromCSV convert between XLSX and CSV.
  • Streaming reads: StreamingReader.ProcessRows streams a worksheet row by row via a callback, for large-file processing without loading the whole sheet into memory.
  • Password protection: Workbook.SetPassword/VerifyPassword protect and check workbook passwords.

Where Aspose.Cells FOSS Can Be Used

  • Data pipelines: Export database query results directly to XLSX or CSV.
  • Report generation: Build styled Excel reports from a Go backend service.
  • Large-file processing: Stream through multi-thousand-row workbooks with StreamingReader instead of loading them fully into memory.
  • ETL workflows: Read input sheets, transform data, and write output workbooks.
  • CI/CD automation: Generate spreadsheet artifacts inside Go-based build pipelines and Docker containers.

Styling, Data Validation, and Tables

  • Style objects: Group 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.
  • Data validation: Worksheet.AddDataValidation attaches list and whole-number range validation rules, each with a custom error title, message, and error style.
  • Tables: Worksheet.AddTable/GetTable create a structured Table range with an optional header row and a named table style.
  • Pictures: Worksheet.AddPicture embeds an image Picture with SetAnchor(row, col) positioning.

Developer Experience

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.

Create a Workbook and Write Cells

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)
}

Add Data Validation Rules

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)
}

Stream Large Workbooks Row-by-Row

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)
}

Frequently Asked Questions

What is the licensing model for Aspose.Cells FOSS for Go?

Aspose.Cells FOSS for Go is released under the MIT License, which permits commercial and open-source use.

Can I use it in commercial products?

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.

How do I install Aspose.Cells FOSS for Go?

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.

Are there any external dependencies?

No. go.mod declares no require entries — the library is built entirely on the Go standard library.

Can I process large workbooks without loading them fully into memory?

Yes. StreamingReader.ProcessRows reads a worksheet row by row through a callback, avoiding a full in-memory load.

  

Support and Learning Resources