Menu

Tree [845a27] master /
 History

HTTPS access


File Date Author Commit
 .github 2025-05-14 xuri xuri [72b731] This closes #2132, fix a v2.9.1 regression bug ...
 test 2023-07-11 David David [2c8dc5] This closes #1169, initialize add form controls...
 .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-05-26 xiaoq898 xiaoq898 [5bd964] Skip fallback to default font size when create ...
 README_zh.md 2025-05-26 xiaoq898 xiaoq898 [5bd964] Skip fallback to default font size when create ...
 adjust.go 2025-05-09 Now-Shimmer Now-Shimmer [094ff3] This related with #2123, made editAs attribute ...
 adjust_test.go 2025-05-07 R3dByt3 R3dByt3 [8fdc26] This fixes #2001 and fixes #2002. Breaking chan...
 calc.go 2025-04-09 timesince timesince [6007d2] Simplifying code with directly swap the values ...
 calc_test.go 2025-05-27 xuri xuri [c46099] This closes #2145, remove all leading equal sym...
 calcchain.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 calcchain_test.go 2025-05-27 xuri xuri [c46099] This closes #2145, remove all leading equal sym...
 cell.go 2025-07-07 xuri xuri [f47b3d] This closes #2167, count characters as single r...
 cell_test.go 2025-07-07 xuri xuri [f47b3d] This closes #2167, count characters as single r...
 chart.go 2025-08-09 Leo012345678 Leo012345678 [b372bd] Add check transparency value when create chart ...
 chart_test.go 2025-08-09 Leo012345678 Leo012345678 [b372bd] Add check transparency value when create chart ...
 col.go 2025-05-09 Now-Shimmer Now-Shimmer [094ff3] This related with #2123, made editAs attribute ...
 col_test.go 2025-05-09 Now-Shimmer Now-Shimmer [094ff3] This related with #2123, made editAs attribute ...
 crypt.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 crypt_test.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 datavalidation.go 2025-05-17 Yi Deng Yi Deng [bb1105] This closes #2133, support delete data validati...
 datavalidation_test.go 2025-05-17 Yi Deng Yi Deng [bb1105] This closes #2133, support delete data validati...
 date.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 date_test.go 2024-02-25 xuri xuri [688808] This closes #1819, formula calculation engine s...
 docProps.go 2025-06-14 MengZhongYuan MengZhongYuan [d434ac] This closes #2146, introduce 2 new functions Ge...
 docProps_test.go 2025-06-14 MengZhongYuan MengZhongYuan [d434ac] This closes #2146, introduce 2 new functions Ge...
 drawing.go 2025-07-17 xuri xuri [dd0713] This closes #2176, support set transparency for...
 drawing_test.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 errors.go 2025-07-17 xuri xuri [dd0713] This closes #2176, support set transparency for...
 errors_test.go 2021-08-14 xuri xuri [48c16d] Improve security and simplify code
 excelize.go 4 days ago a2659802 a2659802 [845a27] This closes #2199, add new function SetZipWrite...
 excelize.svg 2019-09-15 xuri xuri [8922f6] Combine functions:
 excelize_test.go 4 days ago a2659802 a2659802 [845a27] This closes #2199, add new function SetZipWrite...
 file.go 4 days ago a2659802 a2659802 [845a27] This closes #2199, add new function SetZipWrite...
 file_test.go 4 days ago a2659802 a2659802 [845a27] This closes #2199, add new function SetZipWrite...
 go.mod 2025-07-30 black-butler black-butler [d13cd9] Add optional parameter withoutValues for the Ge...
 go.sum 2025-07-30 black-butler black-butler [d13cd9] Add optional parameter withoutValues for the Ge...
 hsl.go 2024-02-25 xuri xuri [688808] This closes #1819, formula calculation engine s...
 lib.go 2025-06-25 MengZhongYuan MengZhongYuan [55e152] This closes #2024, add TempDir field in the Opt...
 lib_test.go 2025-04-26 shcabin shcabin [b9f2c9] This closes #1961, add shared formula cell cach...
 logo.png 2019-03-20 xuri xuri [beff7b] Typo fixed and godoc updated
 merge.go 2025-07-30 black-butler black-butler [d13cd9] Add optional parameter withoutValues for the Ge...
 merge_test.go 2025-07-30 black-butler black-butler [d13cd9] Add optional parameter withoutValues for the Ge...
 numfmt.go 2025-08-05 Copilot Copilot [5d2ee5] This closes #2192, made special date format res...
 numfmt_test.go 2025-08-05 Copilot Copilot [5d2ee5] This closes #2192, made special date format res...
 picture.go 2025-05-09 Now-Shimmer Now-Shimmer [094ff3] This related with #2123, made editAs attribute ...
 picture_test.go 2025-05-27 xuri xuri [c46099] This closes #2145, remove all leading equal sym...
 pivotTable.go 2025-07-25 Hong Jiarong Hong Jiarong [fbcf65] This closes #2180, fix add pivot table caused w...
 pivotTable_test.go 2025-07-05 Leopard31415926 Leopard31415926 [4ac39a] This closes #2161, fix panic on read unsupporte...
 rows.go 2025-07-06 xuri xuri [38f11c] Support set dash line and marker border type of...
 rows_test.go 2025-05-27 xuri xuri [c46099] This closes #2145, remove all leading equal sym...
 shape.go 2025-07-17 xuri xuri [dd0713] This closes #2176, support set transparency for...
 shape_test.go 2025-07-17 xuri xuri [dd0713] This closes #2176, support set transparency for...
 sheet.go 2025-07-31 Neugls Neugls [ce06e7] Optimize the GetSheetDimension function by pars...
 sheet_test.go 2025-07-31 Neugls Neugls [ce06e7] Optimize the GetSheetDimension function by pars...
 sheetpr.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 sheetpr_test.go 2023-11-10 xuri xuri [c7acf4] Support update data validations on inserting/de...
 sheetview.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 sheetview_test.go 2022-12-29 xuri xuri [f58dab] Breaking change: changed the function signature...
 slicer.go 2025-07-17 xuri xuri [dd0713] This closes #2176, support set transparency for...
 slicer_test.go 2024-10-25 xuri xuri [0d5d1c] This closes #2015, fix a v2.9.0 regression bug ...
 sparkline.go 2025-07-17 xuri xuri [dd0713] This closes #2176, support set transparency for...
 sparkline_test.go 2023-11-10 xuri xuri [c7acf4] Support update data validations on inserting/de...
 stream.go 2025-06-25 MengZhongYuan MengZhongYuan [55e152] This closes #2024, add TempDir field in the Opt...
 stream_test.go 2025-06-25 MengZhongYuan MengZhongYuan [55e152] This closes #2024, add TempDir field in the Opt...
 styles.go 2025-07-17 xuri xuri [dd0713] This closes #2176, support set transparency for...
 styles_test.go 2025-05-25 Ali Vatandoost Ali Vatandoost [b65c16] Add set and get `Charset` and `VertAlign` to fo...
 table.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 table_test.go 2024-03-04 xuri xuri [f20bbd] This closes #1830, closes #1831, and closes #1833
 templates.go 2025-07-06 xuri xuri [38f11c] Support set dash line and marker border type of...
 vml.go 2025-07-07 xuri xuri [f47b3d] This closes #2167, count characters as single r...
 vmlDrawing.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 vml_test.go 2025-04-11 xuri xuri [f85dae] This closes #2113, AddFormControl function supp...
 workbook.go 2025-06-14 MengZhongYuan MengZhongYuan [d434ac] This closes #2146, introduce 2 new functions Ge...
 workbook_test.go 2025-03-06 xuri xuri [d6931a] Add optional value checking for CalcMode and Re...
 xmlApp.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 xmlCalcChain.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 xmlChart.go 2025-07-17 xuri xuri [dd0713] This closes #2176, support set transparency for...
 xmlChartSheet.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 xmlComments.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 xmlContentTypes.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 xmlCore.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 xmlCustom.go 2025-06-14 MengZhongYuan MengZhongYuan [d434ac] This closes #2146, introduce 2 new functions Ge...
 xmlDecodeDrawing.go 2025-05-09 Now-Shimmer Now-Shimmer [094ff3] This related with #2123, made editAs attribute ...
 xmlDrawing.go 2025-07-17 xuri xuri [dd0713] This closes #2176, support set transparency for...
 xmlMetaData.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 xmlPivotCache.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 xmlPivotTable.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 xmlSharedStrings.go 2025-05-25 Ali Vatandoost Ali Vatandoost [b65c16] Add set and get `Charset` and `VertAlign` to fo...
 xmlSlicers.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 xmlStyles.go 2025-07-17 xuri xuri [dd0713] This closes #2176, support set transparency for...
 xmlTable.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 xmlTheme.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 xmlWorkbook.go 2025-03-16 hm3248 hm3248 [d399e7] Breaking changes: Go 1.23 and later required fo...
 xmlWorksheet.go 2025-05-24 JerryLuo-2005 JerryLuo-2005 [c85311] Update comment for xlsxDataValidation data stru...

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.23.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.

gopher.{ai,svg,png} was created by Takuya Ueda. Licensed under the Creative Commons 3.0 Attributions license.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.