Introduction

Aspose.Cells FOSS for Go is a pure-Go library for working with Excel spreadsheets. It exposes an API for creating new workbooks from scratch, writing and styling cell values, applying data validation rules, building structured tables, embedding pictures, and reading large .xlsx files a row at a time — all without any native C or C++ dependencies.

The library is available as a Go module at github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Go and is released under the MIT license. Install it with go get github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Go/v26 into any Go 1.24+ project.

This post covers the core capabilities: cell styling, data validation, tables, pictures, and streaming reads.


Key Features

Cell Styling

Group Font, Fill, Alignment, and Border settings into a reusable Style, then apply it to a cell with Cell.SetStyle:

wb := cells_foss.NewWorkbook()
ws := wb.Worksheets[0]

boldStyle := cells_foss.NewStyle()
boldStyle.Font.Bold = true
boldStyle.Font.Size = 12

cell, _ := ws.Cells().Get("A1")
cell.SetStyle(boldStyle)

Alignment controls Horizontal, Vertical, and WrapText; Border controls the Top, Bottom, Left, and Right rule visibility plus Color.

Data Validation

Worksheet.AddDataValidation attaches a validation rule to a cell range. The DataValidation struct carries the rule Type, one or two Formula values, and error-message fields:

wb := cells_foss.NewWorkbook()
ws := wb.Worksheets[0]

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,
}
ws.AddDataValidation("A2:A10", dv)

Tables

Worksheet.AddTable creates a structured Table over a range, with an optional header row and a named table style:

wb := cells_foss.NewWorkbook()
ws := wb.Worksheets[0]
ws.Cells().Set("A1", "Item")
ws.Cells().Set("B1", "Qty")

tbl := ws.AddTable("A1:B2")
tbl.HasHeaderRow = true
tbl.StyleName = "TableStyleMedium6"

Pictures

Worksheet.AddPicture embeds an image; Picture.SetAnchor(row, col) positions it:

wb := cells_foss.NewWorkbook()
ws := wb.Worksheets[0]
imageBytes := []byte{} // populate with real image bytes before use

pic := &cells_foss.Picture{Data: imageBytes, Format: "png"}
ws.AddPicture(pic)
pic.SetAnchor(5, 0)

Streaming Large Files

StreamingReader reads a worksheet row by row through a callback, so a multi-thousand-row workbook never has to be fully loaded into memory:

sr := cells_foss.NewStreamingReader("large_workbook.xlsx")
err := sr.ProcessRows("Sheet1", func(rowIdx int, cells map[string]string) error {
	// process one row at a time
	return nil
})
if err != nil {
	fmt.Printf("Error streaming: %v\n", err)
}

Quick Start

Install the module:

go get github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Go/v26

A minimal workflow — create a workbook, write two cells, bold the header, and save:

package main

import (
	"fmt"

	cells_foss "github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Go/v26/aspose/cells_foss"
)

func main() {
	wb := cells_foss.NewWorkbook()
	ws := wb.Worksheets[0]

	ws.Cells().Set("A1", "Product")
	ws.Cells().Set("B1", "Revenue")

	boldStyle := cells_foss.NewStyle()
	boldStyle.Font.Bold = true
	for _, ref := range []string{"A1", "B1"} {
		cell, _ := ws.Cells().Get(ref)
		cell.SetStyle(boldStyle)
	}

	if err := wb.Save("report.xlsx"); err != nil {
		fmt.Printf("Error saving workbook: %v\n", err)
		return
	}
	fmt.Println("Workbook saved to report.xlsx")
}

Supported Formats

FormatExtensionReadWrite
XLSX.xlsx
CSV.csv

XLSX workbooks are built in memory with NewWorkbook and written with Workbook.Save. CSV is bidirectional via Workbook.ImportFromCSV and Workbook.ExportToCSV.


Open Source & Licensing

Aspose.Cells FOSS for Go is released under the MIT license. There are no usage restrictions, no runtime fees, and no registration requirements. The source code is available at github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Go.

Commercial use is permitted under the MIT license terms. If your project requires enterprise-grade support, extended format coverage, or cloud integration, the Aspose.Cells — Enterprise Product Family is a separate commercial offering.


Getting Started