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

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

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.