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

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

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.