https://github.com/360EntSecGroup-Skylar/excelize

xuri f5a20fa03f Fixed #823, 12/24 hours time format parsing error %!s(int64=3) %!d(string=hai) anos
.github d1926675f8 - Resolve #627, improve multi-series line chart compatibility with KingSoft WPS %!s(int64=4) %!d(string=hai) anos
test afe2ebc261 This improves compatibility for absolute XML path, Windows-style directory separator and inline namespace; %!s(int64=3) %!d(string=hai) anos
.gitignore 61057c58d3 Number format read fix (#741) %!s(int64=3) %!d(string=hai) anos
.travis.yml f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
CODE_OF_CONDUCT.md 023dba7265 Fix #576, serialize by fields order on stream flush %!s(int64=4) %!d(string=hai) anos
CONTRIBUTING.md e51aff2d95 Resolve #570, flat columns for the column's operation %!s(int64=4) %!d(string=hai) anos
LICENSE ec45d67e59 binary search in range lookup and new formula function: LOOKUP %!s(int64=3) %!d(string=hai) anos
PULL_REQUEST_TEMPLATE.md df6b0d9ff4 Create PULL_REQUEST_TEMPLATE.md %!s(int64=6) %!d(string=hai) anos
README.md f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
README_zh.md f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
SECURITY.md 475fbf3856 Create SECURITY.md %!s(int64=5) %!d(string=hai) anos
adjust.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
adjust_test.go 1f329e8f96 This closes #774, closes #775 and closes #776 %!s(int64=3) %!d(string=hai) anos
calc.go 80d832022f #65 fn: IRR nad MIRR %!s(int64=3) %!d(string=hai) anos
calc_test.go 80d832022f #65 fn: IRR nad MIRR %!s(int64=3) %!d(string=hai) anos
calcchain.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
calcchain_test.go ae2865d923 Improve code coverage unit tests %!s(int64=4) %!d(string=hai) anos
cell.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
cell_test.go f5a20fa03f Fixed #823, 12/24 hours time format parsing error %!s(int64=3) %!d(string=hai) anos
chart.go 1559dd31be Support specifies that each data marker in the series has a different color %!s(int64=3) %!d(string=hai) anos
chart_test.go dbe88d723e Fix UpdateLinkedValue which returns an error when has graph sheet (#793) %!s(int64=3) %!d(string=hai) anos
col.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
col_test.go 71bd5e1959 fix incorrect default column from GetColWidth %!s(int64=3) %!d(string=hai) anos
comment.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
comment_test.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
crypt.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
crypt_test.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
datavalidation.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
datavalidation_test.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
date.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
date_test.go 2514bb16c6 Fix #724, standardize variable naming and update unit tests %!s(int64=4) %!d(string=hai) anos
docProps.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
docProps_test.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
drawing.go a13b21fe07 fixed the negative values series missing chart color, #65 fn: CUMIPMT and CUMPRINC %!s(int64=3) %!d(string=hai) anos
drawing_test.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
errors.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
errors_test.go 83eedce70d Export ExcelDateToTime function to convert excel date to time %!s(int64=4) %!d(string=hai) anos
excelize.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
excelize.svg 8922f65978 Combine functions: %!s(int64=5) %!d(string=hai) anos
excelize_test.go 2af96c0714 #65 fn: N, PERCENTILE.INC and T %!s(int64=3) %!d(string=hai) anos
file.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
file_test.go 36b7990d6b lint issue fixed and new formula function: ATAN, AVERAGE, AVERAGEA, CONCAT, CONCATENATE, COUNT, COUNTBLANK, MAX %!s(int64=3) %!d(string=hai) anos
go.mod d42834f3a8 update dependencies module and bump version 2.4.0 %!s(int64=3) %!d(string=hai) anos
go.sum d42834f3a8 update dependencies module and bump version 2.4.0 %!s(int64=3) %!d(string=hai) anos
hsl.go 3e004d900b Comments style changed. %!s(int64=6) %!d(string=hai) anos
lib.go 737b7839a2 Fixed #819, read empty after streaming data writing %!s(int64=3) %!d(string=hai) anos
lib_test.go 13e7bce6d2 improvement compatibility for the XML ignorable namespace %!s(int64=4) %!d(string=hai) anos
logo.png beff7b4f3c Typo fixed and godoc updated %!s(int64=5) %!d(string=hai) anos
merge.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
merge_test.go 1fe660df64 - Resolve #485 use sheet index instead of ID %!s(int64=4) %!d(string=hai) anos
picture.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
picture_test.go 2af96c0714 #65 fn: N, PERCENTILE.INC and T %!s(int64=3) %!d(string=hai) anos
pivotTable.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
pivotTable_test.go b83a36a8ae support ShowError option in Pivot table (#802) %!s(int64=3) %!d(string=hai) anos
rows.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
rows_test.go 30549c5e90 fix custom row height check issue %!s(int64=3) %!d(string=hai) anos
shape.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
shape_test.go 09485b3f9f Improve code coverage unit tests %!s(int64=4) %!d(string=hai) anos
sheet.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
sheet_test.go 36b7990d6b lint issue fixed and new formula function: ATAN, AVERAGE, AVERAGEA, CONCAT, CONCATENATE, COUNT, COUNTBLANK, MAX %!s(int64=3) %!d(string=hai) anos
sheetpr.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
sheetpr_test.go bddea1262b This closes #785, support to change tab color; new formula function: FISHER, FISHERINV, GAMMA, GAMMALN, MIN, MINA, PERMUT %!s(int64=3) %!d(string=hai) anos
sheetview.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
sheetview_test.go f2b8798a34 extend cell value load to support custom datetime format (#703) %!s(int64=4) %!d(string=hai) anos
sparkline.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
sparkline_test.go 2af96c0714 #65 fn: N, PERCENTILE.INC and T %!s(int64=3) %!d(string=hai) anos
stream.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
stream_test.go 2af96c0714 #65 fn: N, PERCENTILE.INC and T %!s(int64=3) %!d(string=hai) anos
styles.go f5a20fa03f Fixed #823, 12/24 hours time format parsing error %!s(int64=3) %!d(string=hai) anos
styles_test.go 2af96c0714 #65 fn: N, PERCENTILE.INC and T %!s(int64=3) %!d(string=hai) anos
table.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
table_test.go ca43c65115 Update test for addTable %!s(int64=4) %!d(string=hai) anos
templates.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
vmlDrawing.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlApp.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlCalcChain.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlChart.go 1559dd31be Support specifies that each data marker in the series has a different color %!s(int64=3) %!d(string=hai) anos
xmlChartSheet.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlComments.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlContentTypes.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlCore.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlDecodeDrawing.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlDrawing.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlPivotCache.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlPivotTable.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlSharedStrings.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlStyles.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlTable.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlTheme.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlWorkbook.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos
xmlWorksheet.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 %!s(int64=3) %!d(string=hai) anos

README.md

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 XLSX / XLSM / XLTM 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.15 or later. The full API 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/360EntSecGroup-Skylar/excelize
  • If your packages are managed using Go Modules, please install with following command.
go get github.com/360EntSecGroup-Skylar/excelize/v2

Create spreadsheet

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

package main

import (
    "fmt"

    "github.com/360EntSecGroup-Skylar/excelize/v2"
)

func main() {
    f := excelize.NewFile()
    // Create a new sheet.
    index := f.NewSheet("Sheet2")
    // 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/360EntSecGroup-Skylar/excelize/v2"
)

func main() {
    f, err := excelize.OpenFile("Book1.xlsx")
    if err != nil {
        fmt.Println(err)
        return
    }
    // Get value from cell by given worksheet name and axis.
    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")
    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/360EntSecGroup-Skylar/excelize/v2"
)

func main() {
    categories := map[string]string{
        "A2": "Small", "A3": "Normal", "A4": "Large",
        "B1": "Apple", "C1": "Orange", "D1": "Pear"}
    values := map[string]int{
        "B2": 2, "C2": 3, "D2": 3, "B3": 5, "C3": 2, "D3": 4, "B4": 6, "C4": 7, "D4": 8}
    f := excelize.NewFile()
    for k, v := range categories {
        f.SetCellValue("Sheet1", k, v)
    }
    for k, v := range values {
        f.SetCellValue("Sheet1", k, v)
    }
    if err := f.AddChart("Sheet1", "E1", `{
        "type": "col3DClustered",
        "series": [
        {
            "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":
        {
            "name": "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/360EntSecGroup-Skylar/excelize/v2"
)

func main() {
    f, err := excelize.OpenFile("Book1.xlsx")
    if err != nil {
        fmt.Println(err)
        return
    }
    // Insert a picture.
    if err := f.AddPicture("Sheet1", "A2", "image.png", ""); err != nil {
        fmt.Println(err)
    }
    // Insert a picture to worksheet with scaling.
    if err := f.AddPicture("Sheet1", "D2", "image.jpg",
        `{"x_scale": 0.5, "y_scale": 0.5}`); err != nil {
        fmt.Println(err)
    }
    // Insert a picture offset in the cell with printing support.
    if err := f.AddPicture("Sheet1", "H2", "image.gif", `{
        "x_offset": 15,
        "y_offset": 10,
        "print_obj": true,
        "lock_aspect_ratio": false,
        "locked": false
    }`); 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.