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

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

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.