Favicon of Excelize

Excelize

Excelize is a pure Go library for reading and writing XLAM/XLSM/XLSX/XLTM/XLTX Excel files, including charts, images, and streaming APIs for large data.

Open Source Alternative to:
Excelize website screenshot
Excelize GitHub repository preview

Excelize is a pure Go library for creating, reading, and modifying Microsoft Excel spreadsheet files (XLAM, XLSM, XLSX, XLTM, XLTX). It targets Go developers who need to generate reports, import/export tabular data, or build automation that touches Excel files without shelling out to Office or relying on COM interop. It works with documents produced by Excel 2007 and later, and it aims for compliance with the ECMA-376 Office Open XML standard.

The library exposes a straightforward API: open a file, read cell values or rows, set values, add charts or pictures, and save. It also provides streaming APIs for cases where a worksheet holds a large amount of data and loading everything into memory isn't practical.

Key features

  • Pure Go implementation: no cgo, no dependency on Microsoft Office or external binaries, so it runs anywhere Go runs.
  • Broad format support: reads and writes XLAM, XLSM, XLSX, XLTM, and XLTX files.
  • Cell and row access: get or set individual cell values, or pull entire rows with GetRows.
  • Chart generation: build charts (bar, column, 3D, and others) tied to worksheet data or standalone, with title and series configuration.
  • Picture embedding: insert PNG, JPEG, or GIF images into worksheets with scaling, offset, and print/lock options.
  • Streaming API: read or write worksheets with large datasets without loading the whole file into memory.
  • Coordinate helpers: utility functions like CoordinatesToCellName for converting row/column indices to cell references.
  • ECMA-376 compliance: XML structure follows part 1 of the 5th edition of the Office Open XML standard, aiming for compatibility with files Excel itself produces.

Ideal use cases

Excelize fits well when a Go backend needs to generate Excel reports on the fly, for example exporting database query results, analytics dashboards, or invoices as XLSX files for download. It's also a good fit for batch processing: reading uploaded spreadsheets, validating or transforming rows, and writing the result back out, all inside a Go service with no external dependencies.

It works for building charts and visual reports directly inside generated workbooks, and for embedding images (logos, screenshots, generated graphics) into spreadsheets programmatically. The streaming API makes it suitable for exporting or importing large datasets, such as tens of thousands of rows, where holding the entire workbook in memory would be wasteful.

It is not the right tool if you need a spreadsheet UI, formula engine parity with Excel's full function set, or real-time collaborative editing; Excelize is a file-format library, not an application. If your stack isn't Go, or if you need to manipulate legacy binary XLS (pre-2007) files exclusively, look elsewhere, since Excelize targets the OOXML-based formats used by Excel 2007 and later.

Installation

Excelize is distributed as a Go module. Add it to your project with go get:

go get github.com/xuri/excelize/v2

If your project doesn't use Go Modules yet, set that up first; Excelize versions above v1 are published under the /v2 module path.

A minimal example that creates a spreadsheet:

package main

import (
    "fmt"

    "github.com/xuri/excelize/v2"
)

func main() {
    f := excelize.NewFile()
    defer func() {
        if err := f.Close(); err != nil {
            fmt.Println(err)
        }
    }()
    f.SetCellValue("Sheet1", "B2", 100)
    if err := f.SaveAs("Book1.xlsx"); err != nil {
        fmt.Println(err)
    }
}

Reading a file follows the same pattern: call excelize.OpenFile("Book1.xlsx"), use GetCellValue or GetRows to pull data, and close the file when done. Full API docs are available at pkg.go.dev and the project's documentation site.

Frequently asked questions

Share:

Stars
21K
Forks
2K
Last commit
17 hours ago
Repository age
10 years
License
BSD-3-Clause
Self-hosted
No
Activity score
82/100
View Repository
Built with:
Ad
Favicon

 

  
 

Similar to Excelize

Favicon

 

  
 
Favicon

 

  
 
Favicon