Menu

Tree [e799e9] master /
 History

HTTPS access


File Date Author Commit
 .github 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 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 2024-12-12 xuri xuri [b53bad] Breaking changes: Go 1.20 and later required
 README.md 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 README_zh.md 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 adjust.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 adjust_test.go 2025-05-07 R3dByt3 R3dByt3 [8fdc26] This fixes #2001 and fixes #2002. Breaking chan...
 calc.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 calc_test.go 2025-09-04 zhuyanhuazhuyanhua zhuyanhuazhuyanhua [aca295] Add unit tests for the BAHTTEXT formula functio...
 calcchain.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 calcchain_test.go 2025-05-27 xuri xuri [c46099] This closes #2145, remove all leading equal sym...
 cell.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 cell_test.go 2025-07-07 xuri xuri [f47b3d] This closes #2167, count characters as single r...
 chart.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 chart_test.go 2025-09-02 crush-wu crush-wu [9e0c94] Add 4 stock chart support for AddChart and AddC...
 col.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 col_test.go 2025-05-09 Now-Shimmer Now-Shimmer [094ff3] This related with #2123, made editAs attribute ...
 crypt.go 7 days ago sqdtss sqdtss [e799e9] This closes #2237, fix panic when open encrypte...
 crypt_test.go 7 days ago sqdtss sqdtss [e799e9] This closes #2237, fix panic when open encrypte...
 datavalidation.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 datavalidation_test.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 date.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 date_test.go 2024-02-25 xuri xuri [688808] This closes #1819, formula calculation engine s...
 docProps.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 docProps_test.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 drawing.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 drawing_test.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 errors.go 2025-11-08 jesusfelix951-lang jesusfelix951-lang [d97f1a] Return error if adding comment on a cell which ...
 errors_test.go 2021-08-14 xuri xuri [48c16d] Improve security and simplify code
 excelize.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 excelize.svg 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 excelize_test.go 2025-10-05 shcabin shcabin [c12dca] This related to #2080, support blank padding in...
 file.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 file_test.go 2025-08-19 a2659802 a2659802 [845a27] This closes #2199, add new function SetZipWrite...
 go.mod 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 go.sum 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 hsl.go 2024-02-25 xuri xuri [688808] This closes #1819, formula calculation engine s...
 lib.go 2025-11-10 shcabin shcabin [3d2358] optimize: convert using continued fractions fun...
 lib_test.go 2025-11-10 shcabin shcabin [3d2358] optimize: convert using continued fractions fun...
 logo.png 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 merge.go 2025-10-25 wangacc wangacc [f0a56d] This closes #2226, optimize overlap merged cell...
 merge_test.go 2025-10-25 wangacc wangacc [f0a56d] This closes #2226, optimize overlap merged cell...
 numfmt.go 2025-11-10 shcabin shcabin [3d2358] optimize: convert using continued fractions fun...
 numfmt_test.go 2025-11-10 shcabin shcabin [3d2358] optimize: convert using continued fractions fun...
 picture.go 2025-11-12 xuri xuri [bfa81a] This closes #2234, allowing insert ICO format i...
 picture_test.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 pivotTable.go 2025-10-22 Simmons25 Simmons25 [ccaddf] Fix extractPivotTableField function panic on in...
 pivotTable_test.go 2025-07-05 Leopard31415926 Leopard31415926 [4ac39a] This closes #2161, fix panic on read unsupporte...
 rows.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 rows_test.go 2025-05-27 xuri xuri [c46099] This closes #2145, remove all leading equal sym...
 shape.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 shape_test.go 2025-07-17 xuri xuri [dd0713] This closes #2176, support set transparency for...
 sheet.go 2025-11-12 xuri xuri [bfa81a] This closes #2234, allowing insert ICO format i...
 sheet_test.go 2025-09-01 torotake torotake [2e1d05] This closes #2205, fix string counting and trun...
 sheetpr.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 sheetpr_test.go 2023-11-10 xuri xuri [c7acf4] Support update data validations on inserting/de...
 sheetview.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 sheetview_test.go 2022-12-29 xuri xuri [f58dab] Breaking change: changed the function signature...
 slicer.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 slicer_test.go 2024-10-25 xuri xuri [0d5d1c] This closes #2015, fix a v2.9.0 regression bug ...
 sparkline.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 sparkline_test.go 2023-11-10 xuri xuri [c7acf4] Support update data validations on inserting/de...
 stream.go 2025-11-13 radam9 radam9 [8bf639] Fix: skipped column style bug in StreamWriter's...
 stream_test.go 2025-11-13 radam9 radam9 [8bf639] Fix: skipped column style bug in StreamWriter's...
 styles.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 styles_test.go 2025-05-25 Ali Vatandoost Ali Vatandoost [b65c16] Add set and get `Charset` and `VertAlign` to fo...
 table.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 table_test.go 2024-03-04 xuri xuri [f20bbd] This closes #1830, closes #1831, and closes #1833
 templates.go 2025-11-12 xuri xuri [bfa81a] This closes #2234, allowing insert ICO format i...
 vml.go 2025-11-12 xuri xuri [bfa81a] This closes #2234, allowing insert ICO format i...
 vmlDrawing.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 vml_test.go 2025-11-08 jesusfelix951-lang jesusfelix951-lang [d97f1a] Return error if adding comment on a cell which ...
 workbook.go 2025-11-12 xuri xuri [bfa81a] This closes #2234, allowing insert ICO format i...
 workbook_test.go 2025-03-06 xuri xuri [d6931a] Add optional value checking for CalcMode and Re...
 xmlApp.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlCalcChain.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlChart.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlChartSheet.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlComments.go 2025-11-08 jesusfelix951-lang jesusfelix951-lang [d97f1a] Return error if adding comment on a cell which ...
 xmlContentTypes.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlCore.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlCustom.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlDecodeDrawing.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlDrawing.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlMetaData.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlPivotCache.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlPivotTable.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlSharedStrings.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlSlicers.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlStyles.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlTable.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlTheme.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlWorkbook.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required
 xmlWorksheet.go 2025-10-13 xuri xuri [525218] Update docs for Go version 1.24.0 required

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.24.0 or later. The full docs can be seen using go's built-in documentation tool, or online at 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.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.