Menu

Tree [2694a3] master /
 History

HTTPS access


File Date Author Commit
 .github 2026-04-02 martskins martskins [2694a3] Update dependencies module to fix vulnerabiliti...
 test 2025-11-02 pegasscience-cyber pegasscience-cyber [8325cf] Update TIF image for fix generated TestSetSheet...
 .gitignore 2022-11-02 xuri xuri [db2d08] This closes #1204, breaking changes for add com...
 LICENSE 2026-01-05 杨春 杨春 [04f6d6] Ref #2075, add new function SetColVisible for s...
 README.md 2026-03-23 Debug Doctor Debug Doctor [48a958] Breaking changes for the AddChart, AddChartShee...
 README_zh.md 2026-03-23 Debug Doctor Debug Doctor [48a958] Breaking changes for the AddChart, AddChartShee...
 adjust.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 adjust_test.go 2026-03-13 Igor Khodyrev Igor Khodyrev [a2bda9] Fix autoFitColWidth overriding width with lates...
 calc.go 2026-03-26 Andrey G. Andrey G. [d7456a] Fix formula calculate accuracy for function BIN...
 calc_test.go 2026-03-26 Andrey G. Andrey G. [d7456a] Fix formula calculate accuracy for function BIN...
 calcchain.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 calcchain_test.go 2025-05-27 xuri xuri [c46099] This closes #2145, remove all leading equal sym...
 cell.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 cell_test.go 2026-03-10 yyt yyt [5d6adc] This closes #92, support auto fit columns width...
 chart.go 2026-03-23 Debug Doctor Debug Doctor [48a958] Breaking changes for the AddChart, AddChartShee...
 chart_test.go 2026-03-23 Debug Doctor Debug Doctor [48a958] Breaking changes for the AddChart, AddChartShee...
 col.go 2026-04-02 martskins martskins [2694a3] Update dependencies module to fix vulnerabiliti...
 col_test.go 2026-03-13 Igor Khodyrev Igor Khodyrev [a2bda9] Fix autoFitColWidth overriding width with lates...
 crypt.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 crypt_test.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 datavalidation.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 datavalidation_test.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 date.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 date_test.go 2024-02-25 xuri xuri [688808] This closes #1819, formula calculation engine s...
 docProps.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 docProps_test.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 drawing.go 2026-03-23 Debug Doctor Debug Doctor [48a958] Breaking changes for the AddChart, AddChartShee...
 drawing_test.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 errors.go 2026-03-23 Debug Doctor Debug Doctor [48a958] Breaking changes for the AddChart, AddChartShee...
 errors_test.go 2021-08-14 xuri xuri [48c16d] Improve security and simplify code
 excelize.go 2026-03-22 Roman Sergeev Roman Sergeev [ae7a61] Replace manual nested if-blocks with the built-...
 excelize.svg 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 excelize_test.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 file.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 file_test.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 go.mod 2026-04-02 martskins martskins [2694a3] Update dependencies module to fix vulnerabiliti...
 go.sum 2026-04-02 martskins martskins [2694a3] Update dependencies module to fix vulnerabiliti...
 hsl.go 2024-02-25 xuri xuri [688808] This closes #1819, formula calculation engine s...
 lib.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 lib_test.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 logo.png 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 merge.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 merge_test.go 2025-10-25 wangacc wangacc [f0a56d] This closes #2226, optimize overlap merged cell...
 numfmt.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 numfmt_test.go 2025-11-10 shcabin shcabin [3d2358] optimize: convert using continued fractions fun...
 picture.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 picture_test.go 2026-01-16 xuri xuri [a88014] Ref #2208, add new Name field in GraphicOptions...
 pivotTable.go 2026-04-02 martskins martskins [2694a3] Update dependencies module to fix vulnerabiliti...
 pivotTable_test.go 2026-03-21 zhuhua zhuhua [79a82f] This closes #2154, support set and get selected...
 rows.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 rows_test.go 2025-05-27 xuri xuri [c46099] This closes #2145, remove all leading equal sym...
 shape.go 2026-03-23 Debug Doctor Debug Doctor [48a958] Breaking changes for the AddChart, AddChartShee...
 shape_test.go 2026-03-23 Debug Doctor Debug Doctor [48a958] Breaking changes for the AddChart, AddChartShee...
 sheet.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 sheet_test.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 sheetpr.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 sheetpr_test.go 2025-12-29 Tatsuro Moriyama Tatsuro Moriyama [86cef4] This related #1813, mitigate inserted image asp...
 sheetview.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 sheetview_test.go 2022-12-29 xuri xuri [f58dab] Breaking change: changed the function signature...
 slicer.go 2026-03-23 Debug Doctor Debug Doctor [48a958] Breaking changes for the AddChart, AddChartShee...
 slicer_test.go 2026-03-21 zhuhua zhuhua [79a82f] This closes #2154, support set and get selected...
 sparkline.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 sparkline_test.go 2023-11-10 xuri xuri [c7acf4] Support update data validations on inserting/de...
 stream.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 stream_test.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 styles.go 2026-03-25 Vladislav Anisimov Vladislav Anisimov [0aec9b] Unlock mutex before returning error (#2281)
 styles_test.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 table.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 table_test.go 2024-03-04 xuri xuri [f20bbd] This closes #1830, closes #1831, and closes #1833
 templates.go 2026-03-23 Debug Doctor Debug Doctor [48a958] Breaking changes for the AddChart, AddChartShee...
 vml.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 vmlDrawing.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 vml_test.go 2026-03-23 Debug Doctor Debug Doctor [48a958] Breaking changes for the AddChart, AddChartShee...
 workbook.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 workbook_test.go 2025-03-06 xuri xuri [d6931a] Add optional value checking for CalcMode and Re...
 xmlApp.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlCalcChain.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlChart.go 2026-04-02 martskins martskins [2694a3] Update dependencies module to fix vulnerabiliti...
 xmlChartSheet.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlComments.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlContentTypes.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlCore.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlCustom.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlDecodeDrawing.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlDrawing.go 2026-03-23 Debug Doctor Debug Doctor [48a958] Breaking changes for the AddChart, AddChartShee...
 xmlMetaData.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlPivotCache.go 2026-03-21 zhuhua zhuhua [79a82f] This closes #2154, support set and get selected...
 xmlPivotTable.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlSharedStrings.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlSlicers.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlStyles.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlTable.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlTheme.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlWorkbook.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...
 xmlWorksheet.go 2026-03-16 Egor Gordionok Egor Gordionok [2966ca] Update minimum Go language version required in ...

Read Me

Excelize logo

Build Status Code Coverage Go Report Card go.dev Licenses Donate

Excelize

Introduction

Excelize is a library written in pure Go providing a set of functions that allow you to write to and read from XLAM / XLSM / XLSX / XLTM / XLTX files. Supports reading and writing spreadsheet documents generated by Microsoft Excel™ 2007 and later. Supports complex components by high compatibility, and provided streaming API for generating or reading data from a worksheet with huge amounts of data. This library needs Go version 1.25.0 or later. The full docs can be seen using go's built-in documentation tool, or online at go.dev (pkg.go.dev) and docs reference.

Basic Usage

Installation

go get github.com/xuri/excelize
  • If your packages are managed using Go Modules, please install with following command.
go get github.com/xuri/excelize/v2

Create spreadsheet

Here is a minimal example usage that will create spreadsheet file.

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)
        }
    }()
    // Create a new sheet.
    index, err := f.NewSheet("Sheet2")
    if err != nil {
        fmt.Println(err)
        return
    }
    // Set value of a cell.
    f.SetCellValue("Sheet2", "A2", "Hello world.")
    f.SetCellValue("Sheet1", "B2", 100)
    // Set active sheet of the workbook.
    f.SetActiveSheet(index)
    // Save spreadsheet by the given path.
    if err := f.SaveAs("Book1.xlsx"); err != nil {
        fmt.Println(err)
    }
}

Reading spreadsheet

The following constitutes the bare to read a spreadsheet document.

package main

import (
    "fmt"

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

func main() {
    f, err := excelize.OpenFile("Book1.xlsx")
    if err != nil {
        fmt.Println(err)
        return
    }
    defer func() {
        // Close the spreadsheet.
        if err := f.Close(); err != nil {
            fmt.Println(err)
        }
    }()
    // Get value from cell by given worksheet name and cell reference.
    cell, err := f.GetCellValue("Sheet1", "B2")
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(cell)
    // Get all the rows in the Sheet1.
    rows, err := f.GetRows("Sheet1")
    if err != nil {
        fmt.Println(err)
        return
    }
    for _, row := range rows {
        for _, colCell := range row {
            fmt.Print(colCell, "\t")
        }
        fmt.Println()
    }
}

Add chart to spreadsheet file

With Excelize chart generation and management is as easy as a few lines of code. You can build charts based on data in your worksheet or generate charts without any data in your worksheet at all.

Excelize

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)
        }
    }()
    for idx, row := range [][]interface{}{
        {nil, "Apple", "Orange", "Pear"}, {"Small", 2, 3, 3},
        {"Normal", 5, 2, 4}, {"Large", 6, 7, 8},
    } {
        cell, err := excelize.CoordinatesToCellName(1, idx+1)
        if err != nil {
            fmt.Println(err)
            return
        }
        f.SetSheetRow("Sheet1", cell, &row)
    }
    if err := f.AddChart("Sheet1", "E1", &excelize.Chart{
        Type: excelize.Col3DClustered,
        Series: []excelize.ChartSeries{
            {
                Name:       "Sheet1!$A$2",
                Categories: "Sheet1!$B$1:$D$1",
                Values:     "Sheet1!$B$2:$D$2",
            },
            {
                Name:       "Sheet1!$A$3",
                Categories: "Sheet1!$B$1:$D$1",
                Values:     "Sheet1!$B$3:$D$3",
            },
            {
                Name:       "Sheet1!$A$4",
                Categories: "Sheet1!$B$1:$D$1",
                Values:     "Sheet1!$B$4:$D$4",
            }},
        Title: excelize.ChartTitle{
            Paragraph: []excelize.RichTextRun{
                {
                    Text: "Fruit 3D Clustered Column Chart",
                },
            },
        },
    }); err != nil {
        fmt.Println(err)
        return
    }
    // Save spreadsheet by the given path.
    if err := f.SaveAs("Book1.xlsx"); err != nil {
        fmt.Println(err)
    }
}

Add picture to spreadsheet file

package main

import (
    "fmt"
    _ "image/gif"
    _ "image/jpeg"
    _ "image/png"

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

func main() {
    f, err := excelize.OpenFile("Book1.xlsx")
    if err != nil {
        fmt.Println(err)
        return
    }
    defer func() {
        // Close the spreadsheet.
        if err := f.Close(); err != nil {
            fmt.Println(err)
        }
    }()
    // Insert a picture.
    if err := f.AddPicture("Sheet1", "A2", "image.png", nil); err != nil {
        fmt.Println(err)
    }
    // Insert a picture to worksheet with scaling.
    if err := f.AddPicture("Sheet1", "D2", "image.jpg",
        &excelize.GraphicOptions{ScaleX: 0.5, ScaleY: 0.5}); err != nil {
        fmt.Println(err)
    }
    // Insert a picture offset in the cell with printing support.
    enable, disable := true, false
    if err := f.AddPicture("Sheet1", "H2", "image.gif",
        &excelize.GraphicOptions{
            PrintObject:     &enable,
            LockAspectRatio: false,
            OffsetX:         15,
            OffsetY:         10,
            Locked:          &disable,
        }); err != nil {
        fmt.Println(err)
    }
    // Save the spreadsheet with the origin path.
    if err = f.Save(); err != nil {
        fmt.Println(err)
    }
}

Contributing

Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change. XML is compliant with part 1 of the 5th edition of the ECMA-376 Standard for Office Open XML.

Licenses

This program is under the terms of the BSD 3-Clause License. See https://opensource.org/licenses/BSD-3-Clause.

The Excel logo is a trademark of Microsoft Corporation. This artwork is an adaptation.

The Go gopher was created by Renee French. Licensed under the Creative Commons 4.0 Attributions license.

Gold Sponsors

Gravity

MongoDB Logo MongoDB