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

xuri 5bf3ea6154 This closes #842, avoid empty rows in the tail of the worksheet il y a 3 ans
.github d1926675f8 - Resolve #627, improve multi-series line chart compatibility with KingSoft WPS il y a 4 ans
test afe2ebc261 This improves compatibility for absolute XML path, Windows-style directory separator and inline namespace; il y a 3 ans
.gitignore 61057c58d3 Number format read fix (#741) il y a 3 ans
.travis.yml f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
CODE_OF_CONDUCT.md 023dba7265 Fix #576, serialize by fields order on stream flush il y a 4 ans
CONTRIBUTING.md e51aff2d95 Resolve #570, flat columns for the column's operation il y a 4 ans
LICENSE ec45d67e59 binary search in range lookup and new formula function: LOOKUP il y a 3 ans
PULL_REQUEST_TEMPLATE.md df6b0d9ff4 Create PULL_REQUEST_TEMPLATE.md il y a 6 ans
README.md 5bf3ea6154 This closes #842, avoid empty rows in the tail of the worksheet il y a 3 ans
README_zh.md 5bf3ea6154 This closes #842, avoid empty rows in the tail of the worksheet il y a 3 ans
SECURITY.md 475fbf3856 Create SECURITY.md il y a 5 ans
adjust.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
adjust_test.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
calc.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
calc_test.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
calcchain.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
calcchain_test.go ae2865d923 Improve code coverage unit tests il y a 4 ans
cell.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
cell_test.go f5a20fa03f Fixed #823, 12/24 hours time format parsing error il y a 3 ans
chart.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
chart_test.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
col.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
col_test.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
comment.go a13ef5545e This closes #825, closes #829, closes #830, fix issue when get and add comments on multi authors il y a 3 ans
comment_test.go e5c5ecc379 Fixed #825, improves compatibility for comments with absolute XML path il y a 3 ans
crypt.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
crypt_test.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
datavalidation.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
datavalidation_test.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
date.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
date_test.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
docProps.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
docProps_test.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
drawing.go a13b21fe07 fixed the negative values series missing chart color, #65 fn: CUMIPMT and CUMPRINC il y a 3 ans
drawing_test.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
errors.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
errors_test.go 83eedce70d Export ExcelDateToTime function to convert excel date to time il y a 4 ans
excelize.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
excelize.svg 8922f65978 Combine functions: il y a 5 ans
excelize_test.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
file.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
file_test.go 36b7990d6b lint issue fixed and new formula function: ATAN, AVERAGE, AVERAGEA, CONCAT, CONCATENATE, COUNT, COUNTBLANK, MAX il y a 3 ans
go.mod d42834f3a8 update dependencies module and bump version 2.4.0 il y a 3 ans
go.sum d42834f3a8 update dependencies module and bump version 2.4.0 il y a 3 ans
hsl.go 3e004d900b Comments style changed. il y a 6 ans
lib.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
lib_test.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
logo.png beff7b4f3c Typo fixed and godoc updated il y a 5 ans
merge.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
merge_test.go 1fe660df64 - Resolve #485 use sheet index instead of ID il y a 4 ans
picture.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
picture_test.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
pivotTable.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
pivotTable_test.go b83a36a8ae support ShowError option in Pivot table (#802) il y a 3 ans
rows.go 5bf3ea6154 This closes #842, avoid empty rows in the tail of the worksheet il y a 3 ans
rows_test.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
shape.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
shape_test.go 09485b3f9f Improve code coverage unit tests il y a 4 ans
sheet.go be12cc27f1 This closes #652, new SetColWidth API, support set column width in stream writing mode, and export error message il y a 3 ans
sheet_test.go 36b7990d6b lint issue fixed and new formula function: ATAN, AVERAGE, AVERAGEA, CONCAT, CONCATENATE, COUNT, COUNTBLANK, MAX il y a 3 ans
sheetpr.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
sheetpr_test.go bddea1262b This closes #785, support to change tab color; new formula function: FISHER, FISHERINV, GAMMA, GAMMALN, MIN, MINA, PERMUT il y a 3 ans
sheetview.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
sheetview_test.go f2b8798a34 extend cell value load to support custom datetime format (#703) il y a 4 ans
sparkline.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
sparkline_test.go 2af96c0714 #65 fn: N, PERCENTILE.INC and T il y a 3 ans
stream.go a1e1db1e6f This closes #838, fix wrong worksheet XML path of the stream writer in some case il y a 3 ans
stream_test.go a1e1db1e6f This closes #838, fix wrong worksheet XML path of the stream writer in some case il y a 3 ans
styles.go c8c62c2d2a * This closes #841, fix incorrect build number format in PR #839 il y a 3 ans
styles_test.go c8c62c2d2a * This closes #841, fix incorrect build number format in PR #839 il y a 3 ans
table.go 7e429c5b46 Fixe issue generated file corrupted caused by incorrect default XML namespace attributes il y a 3 ans
table_test.go ca43c65115 Update test for addTable il y a 4 ans
templates.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
vmlDrawing.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
xmlApp.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
xmlCalcChain.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
xmlChart.go 1559dd31be Support specifies that each data marker in the series has a different color il y a 3 ans
xmlChartSheet.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
xmlComments.go a13ef5545e This closes #825, closes #829, closes #830, fix issue when get and add comments on multi authors il y a 3 ans
xmlContentTypes.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
xmlCore.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
xmlDecodeDrawing.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
xmlDrawing.go 7e429c5b46 Fixe issue generated file corrupted caused by incorrect default XML namespace attributes il y a 3 ans
xmlPivotCache.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
xmlPivotTable.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
xmlSharedStrings.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
xmlStyles.go 7e429c5b46 Fixe issue generated file corrupted caused by incorrect default XML namespace attributes il y a 3 ans
xmlTable.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
xmlTheme.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
xmlWorkbook.go f8f699a172 Go 1.15 and later required, #65 fn: IMABS, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMEXP, IMLN and IMLOG10 il y a 3 ans
xmlWorksheet.go 0e0237e62d compatibility with non-standard page setup attributes il y a 3 ans

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