Golang library for reading and writing Microsoft Excel™ (XLSX) files.

Overview

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/xuri/excelize
  • If your packages are managed using Go Modules, please install with following command.
go get github.com/xuri/excelize/v2

Create spreadsheet

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

package main

import (
    "fmt"

    "github.com/xuri/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/xuri/excelize/v2"
)

func main() {
    f, err := excelize.OpenFile("Book1.xlsx")
    if err != nil {
        fmt.Println(err)
        return
    }
    defer func() {
        // Close the spreadsheet.
        if err := f.Close(); err != nil {
            fmt.Println(err)
        }
    }()
    // 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")
    if err != nil {
        fmt.Println(err)
        return
    }
    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/xuri/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/xuri/excelize/v2"
)

func main() {
    f, err := excelize.OpenFile("Book1.xlsx")
    if err != nil {
        fmt.Println(err)
        return
    }
    defer func() {
        // Close the spreadsheet.
        if err := f.Close(); err != nil {
            fmt.Println(err)
        }
    }()
    // 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.

Issues
  • PR 366 Documentation

    PR 366 Documentation

    Description

    #366 Removed ToAlphaString, which is a breaking change, and replaced it with ColumnNumberToName. The documentation however, still has the original name in it. It also changed the signature from a string return value to a (string, error) return value to guard against indexes less than one. This doesn't seem necessary.

    It also appears to have changed the zero based index to a one based index. What was the motivation for these changes?

    Will there be a changelog that lays out other things that are now broken from that PR? It would be helpful to know what the upgrade path looks like.

    opened by mlh758 23
  • macOS can not use

    macOS can not use

    cell := xlsx.GetCellValue("Sheet1", "B2") fmt.Println(cell) // Get all the rows in a sheet. rows := xlsx.GetRows("sheet1") fmt.Println(rows)

    in windows it works normal,but in macOS rows is empty,cell can get value

    opened by a57571735 23
  • SetColStyle not honoring given style

    SetColStyle not honoring given style

    Description SetColStyle seems to be corrupting spreadsheets. It doesn't seem to matter what data is in the column or which column or sheet you use.

    I created this simple code to re-produce it:

    package main
    
    import (
    	"github.com/excelize"
    )
    
    // define globals
    
    var xlfile = "testlocal.xlsx"
    var xlsheetname = "test"
    
    // main
    func main() {
    	var (
    		file *excelize.File
    		err  error
    	)
    	// open the file
    	file, err = excelize.OpenFile(xlfile)
    	errorhandler(err)
    
    	err = file.SetColStyle(xlsheetname, "C", 7)
    	errorhandler(err)
    	file.Save()
    
    }
    
    func errorhandler(e error) {
    	if e != nil {
    		panic(e)
    	}
    }
    

    Steps to reproduce the issue:

    1. Create a spreadsheet named localtest.xlsx and a sheet named test
    2. run this test code against it
    3. open the spreadsheet and see it needs repair

    Describe the results you received: image Repair Log: `

    Repair Result to testlocal5.xml

    Errors were detected in file '/Users/stalt/Documents/go/src/setcoltest/testlocal.xlsx'Repaired Records: Column information from /xl/worksheets/sheet1.xml part

    `

    Describe the results you expected: I expect the column to be formated with

    Output of go version:

    $ go version
    go version go1.10 darwin/amd64
    

    Excelize version or commit ID:

    commit id: 448f552
    

    Environment details (OS, Microsoft Excel™ version, physical, etc.): macOS Mojave 10.14.5 Excel for Mac 16.27 (19071500)

    opened by SteveTalt 20
  • not a valid zip file

    not a valid zip file

    wps

    opened by justdoitgo 19
  • after saving, file looks different

    after saving, file looks different

    1. open xlsx (quite complex formatting - styles and etc)
    2. copy from Col A into Col B
    3. set Col A equal 0
    4. save as a new file - files looks different :(

    some cells at each row can be merged, BUT Col A, and Col B are simple - only style formatting.

    More overs, some rows(quite a lot) that I'm not updating - after saving looks different.

    Let's recap - I only update some simple cells at some rows. Why rows that I'm not touching looks different?! :(

    opened by plandem 16
  • Write to file as stream row by row?

    Write to file as stream row by row?

    Hi, would it be possible to have something like stream-writing to a file in case of lots of rows? Like hitting the excel sheet row limit?

    I'm not so familiar with GoLang's IO, but maybe there is no problem to achieve this?

    For example I have millions of rows to put in excel sheets, and it is obviously memory heavy task. The idea is to read slice of rows from data source, like 100,000 at the time, then write them to the excel file in a loop until all rows was written. In such case there would be produced either excel file with few sheets or few excel files.

    The primary idea is to handle memory consumption to reasonable amounts of RAM, like few gigabytes not tens..

    What's Your opinion?

    enhancement 
    opened by Ryouku 15
  •  Call GetSheetName can not get correct sheetname

    Call GetSheetName can not get correct sheetname

    Description

    GetSheetName can not get correct sheet name just return empty string

    Steps to reproduce the issue:

    1. my xlsx file's first sheet named "basic". so I call GetSheetIndex("basic") get return value is 15
    2. call GetSheetName(15) return value is "" (empty string)

    Describe the results you received: I get an empty string as sheetname

    Describe the results you expected: I expect the return string should be "basic"

    Output of go version:

    go version go1.11 linux/amd64
    

    Excelize version or commit ID:

    eef232f09ecd41b1f8fc199906ce0be64865802e
    

    Environment details (OS, Microsoft Excel™ version, physical, etc.):

    Ubuntu 18.04, wps 2019( can open and eidt excel 2007 xlsx file), thinkpad x1 carbon
    
    opened by virteman 15
  • Performance of large files is really bad

    Performance of large files is really bad

    I see your performance metrics in the docs but the files i'm dealing with can often be up to half a million rows.

    I'm importing from a CSV and as I continually SetCellValues processing each line, the performance of adding those lines gets worse and worse.

    	reader := csv.NewReader(csvBody)
    	const headerRow = 1
    	row := headerRow
    	var headers []string
    	rowstart := time.Now()
    	for {
    		line, err := reader.Read()
    		if err == io.EOF {
    			break
    		} else if err != nil {
    			log.Printf("Error Reading CSV: %+v ", err)
    			return err
    		}
    		if row == headerRow {
    			headers = line
    		}
    		for cellIndex, cellValue := range line {
    			if row > headerRow && stringInSlice(headers[cellIndex], []string{"quantity", "price"}) {
    				cellParsedValue, err := strconv.ParseFloat(cellValue, 64)
    				if err != nil {
    					log.Printf("%s\ncell %d in line %d had invalid value %s", err, cellIndex, row, cellValue)
    					return err
    				}
    				xlsx.SetCellValue("details", fmt.Sprintf("%s%d", excelize.ToAlphaString(cellIndex), row), cellParsedValue)
    			} else {
    				xlsx.SetCellValue("details", fmt.Sprintf("%s%d", excelize.ToAlphaString(cellIndex), row), cellValue)
    			}
    
    		}
    		pow10row := findPow10(row)
    		if row <= pow10row*10 && (row%pow10row == 0 || row%10000 == 0) {
    			elapsed := time.Since(rowstart)
    			log.Printf("Row %d, time elapsed %s", row, elapsed)
    			rowstart = time.Now()
    		}
    		row++
    	}
    

    Describe the results you received: In the log output below, each time elapsed is the difference from the previous log line. you can see that after about 10,000 rows, its starting to get really bad in terms of how long it takes to process each next 10,000 rows.

    2019/04/08 21:38:37 Row 1, time elapsed 1.505084ms
    2019/04/08 21:38:37 Row 2, time elapsed 96.097µs
    2019/04/08 21:38:37 Row 3, time elapsed 101.482µs
    2019/04/08 21:38:37 Row 4, time elapsed 94.35µs
    2019/04/08 21:38:37 Row 5, time elapsed 94.585µs
    2019/04/08 21:38:37 Row 6, time elapsed 96.621µs
    2019/04/08 21:38:37 Row 7, time elapsed 97.552µs
    2019/04/08 21:38:37 Row 8, time elapsed 99.631µs
    2019/04/08 21:38:37 Row 9, time elapsed 108.849µs
    2019/04/08 21:38:37 Row 10, time elapsed 74.078µs
    2019/04/08 21:38:37 Row 20, time elapsed 545.239µs
    2019/04/08 21:38:37 Row 30, time elapsed 513.501µs
    2019/04/08 21:38:37 Row 40, time elapsed 532.816µs
    2019/04/08 21:38:37 Row 50, time elapsed 564.326µs
    2019/04/08 21:38:37 Row 60, time elapsed 669.845µs
    2019/04/08 21:38:37 Row 70, time elapsed 1.508732ms
    2019/04/08 21:38:37 Row 80, time elapsed 666.172µs
    2019/04/08 21:38:37 Row 90, time elapsed 594.624µs
    2019/04/08 21:38:37 Row 100, time elapsed 630.948µs
    2019/04/08 21:38:37 Row 200, time elapsed 7.519094ms
    2019/04/08 21:38:37 Row 300, time elapsed 6.852758ms
    2019/04/08 21:38:37 Row 400, time elapsed 8.674476ms
    2019/04/08 21:38:37 Row 500, time elapsed 8.159781ms
    2019/04/08 21:38:37 Row 600, time elapsed 9.568621ms
    2019/04/08 21:38:37 Row 700, time elapsed 8.916284ms
    2019/04/08 21:38:37 Row 800, time elapsed 10.846477ms
    2019/04/08 21:38:37 Row 900, time elapsed 9.282789ms
    2019/04/08 21:38:37 Row 1000, time elapsed 12.92103ms
    2019/04/08 21:38:37 Row 2000, time elapsed 128.488664ms
    2019/04/08 21:38:37 Row 3000, time elapsed 189.107883ms
    2019/04/08 21:38:37 Row 4000, time elapsed 278.586948ms
    2019/04/08 21:38:38 Row 5000, time elapsed 391.341065ms
    2019/04/08 21:38:38 Row 6000, time elapsed 471.830863ms
    2019/04/08 21:38:39 Row 7000, time elapsed 530.416468ms
    2019/04/08 21:38:39 Row 8000, time elapsed 602.603427ms
    2019/04/08 21:38:40 Row 9000, time elapsed 652.277227ms
    2019/04/08 21:38:41 Row 10000, time elapsed 729.849772ms
    2019/04/08 21:38:52 Row 20000, time elapsed 10.977776474s
    2019/04/08 21:39:10 Row 30000, time elapsed 18.55464695s
    2019/04/08 21:39:37 Row 40000, time elapsed 26.336721766s
    2019/04/08 21:40:10 Row 50000, time elapsed 33.489274657s
    2019/04/08 21:40:51 Row 60000, time elapsed 40.729296603s
    2019/04/08 21:41:39 Row 70000, time elapsed 47.928431496s
    2019/04/08 21:42:34 Row 80000, time elapsed 55.148409674s
    2019/04/08 21:43:36 Row 90000, time elapsed 1m2.4532031s
    2019/04/08 21:44:46 Row 100000, time elapsed 1m9.608536367s
    2019/04/08 21:46:03 Row 110000, time elapsed 1m16.990387462s
    2019/04/08 21:47:27 Row 120000, time elapsed 1m24.146257207s
    2019/04/08 21:48:59 Row 130000, time elapsed 1m31.308584865s
    2019/04/08 21:50:37 Row 140000, time elapsed 1m38.654884213s
    2019/04/08 21:52:23 Row 150000, time elapsed 1m46.000199696s
    2019/04/08 21:54:16 Row 160000, time elapsed 1m53.238934707s
    2019/04/08 21:56:17 Row 170000, time elapsed 2m0.485714266s
    2019/04/08 21:58:25 Row 180000, time elapsed 2m7.897305904s
    2019/04/08 22:00:40 Row 190000, time elapsed 2m15.234462928s
    2019/04/08 22:03:03 Row 200000, time elapsed 2m23.134322152s
    2019/04/08 22:05:34 Row 210000, time elapsed 2m30.40930936s
    2019/04/08 22:08:11 Row 220000, time elapsed 2m37.873410076s
    2019/04/08 22:10:59 Row 230000, time elapsed 2m47.92659603s
    2019/04/08 22:13:58 Row 240000, time elapsed 2m58.625053178s
    2019/04/08 22:17:08 Row 250000, time elapsed 3m10.348595584s
    2019/04/08 22:20:29 Row 260000, time elapsed 3m20.726383957s
    2019/04/08 22:24:08 Row 270000, time elapsed 3m38.840478421s
    2019/04/08 22:28:12 Row 280000, time elapsed 4m4.294031488s
    2019/04/08 22:32:43 Row 290000, time elapsed 4m30.85305806s
    2019/04/08 22:37:45 Row 300000, time elapsed 5m2.183625905s
    2019/04/08 22:43:18 Row 310000, time elapsed 5m33.135633645s
    2019/04/08 22:49:22 Row 320000, time elapsed 6m3.47749514s
    2019/04/08 22:55:56 Row 330000, time elapsed 6m33.647828s
    2019/04/08 23:02:59 Row 340000, time elapsed 7m3.546443285s
    2019/04/08 23:10:35 Row 350000, time elapsed 7m35.978277292s
    2019/04/08 23:18:43 Row 360000, time elapsed 8m8.039533099s
    2019/04/08 23:27:22 Row 370000, time elapsed 8m38.447390938s
    2019/04/08 23:36:33 Row 380000, time elapsed 9m11.603785808s
    2019/04/08 23:46:15 Row 390000, time elapsed 9m41.515021912s
    2019/04/08 23:56:17 Row 400000, time elapsed 10m2.085553551s
    2019-04-09
    2019/04/09 00:06:42 Row 410000, time elapsed 10m25.252517462s
    2019/04/09 00:17:38 Row 420000, time elapsed 10m55.909756693s
    

    Describe the results you expected:

    if there was a direct way to import a CSV or some method to speed this sort of import up, it would be really useful

    Excelize version or commit ID:

      digest = "1:9b67e96a030cc96a3bef1d7cb1143f1e13440f1087eee5999fa9ba5514c1027c"
      name = "github.com/360EntSecGroup-Skylar/excelize"
      packages = ["."]
      pruneopts = ""
      revision = "dea7ba0ec43a4c29a6642d02b6edc73b8b0369f0"
      version = "v1.4.1"
    

    Environment details (OS, Microsoft Excel™ version, physical, etc.): The above log was captured from an AWS Fargate Docker task running with 4096 CPU units and 30720 MiB

    opened by jjmartin 15
  • Corrupted xlsx after write operation

    Corrupted xlsx after write operation

    Thank you for your great work on excelize. Reading works like a charm. But I have an issue with writing.

    I update one cell, save and XLSX file is corrupted.

    Input file: source_file.xlsx Output corrupted file: Workbook.xlsx

    How I am writing to the file

    xlsx, err := excelize.OpenFile(path)
    xlsx.SetCellInt("Sheet1", "I15", 100)
    err := xlsx.SaveAs("./Workbook.xlsx")
    

    Erro message during opening Workbook.xlsx image

    And error if I try to recover the workbook: Replaced Part: /xl/worksheets/sheet1.xml part with XML error. Load error. Line 2, column 213397. Removed Records: Formula from /xl/calcChain.xml part (Calculation properties)

    go env

    set GOARCH=amd64
    set GOBIN=
    set GOEXE=.exe
    set GOHOSTARCH=amd64
    set GOHOSTOS=windows
    set GOOS=windows
    set GOPATH=C:\Users\stanislav.valasek\go
    set GORACE=
    set GOROOT=C:\Go
    set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
    set GCCGO=gccgo
    set CC=gcc
    set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
    set CXX=g++
    set CGO_ENABLED=1
    set CGO_CFLAGS=-g -O2
    set CGO_CPPFLAGS=
    set CGO_CXXFLAGS=-g -O2
    set CGO_FFLAGS=-g -O2
    set CGO_LDFLAGS=-g -O2
    set PKG_CONFIG=pkg-config
    
    opened by valasek 14
  • How to upload excel file to database by read header column name

    How to upload excel file to database by read header column name

    How to upload excel file to database by read header column name/first row as index

    opened by baskara8 13
  • DRAFT: add adjust function for drawings

    DRAFT: add adjust function for drawings

    PR Details

    Add an adjusting of drawing coordinates

    Description

    Added functions to get drawing data and adjust all it's anchors' coordinates Now it's can't decode xml-files because of structs' fields tags Not implemented functions to update anchor's innerXML data with changes and to make correct document with current anchor's innerXML data

    Related Issue

    issue

    Motivation and Context

    In my work project We need add and delete cols and rows, and document content should move adaptively

    How Has This Been Tested

    It should be tested with adding picture in sheet and then add few rows before picture target cell

    Types of changes

    • [ ] Docs change / refactoring / dependency upgrade
    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)

    Checklist

    • [ x] My code follows the code style of this project.
    • [ ] My change requires a change to the documentation.
    • [ ] I have updated the documentation accordingly.
    • [x ] I have read the CONTRIBUTING document.
    • [ ] I have added tests to cover my changes.
    • [ ] All new and existing tests passed.
    opened by kjushka 1
  • Adjusting pictures/drawing references

    Adjusting pictures/drawing references

    Hello, when we use pictures inside the sheet, after inserting more columns or delete few ones before picture it keeps its place and reference. I write some test:

    func TestParseParse(t *testing.T) {
    	bodyData, err := ioutil.ReadFile("../../test_data/xlsx/test.xlsx")
    	require.NoError(t, err)
    
    	r := bytes.NewReader(bodyData)
    	f, err := excelize.OpenReader(r)
    	require.NoError(t, err)
    
    	for _, sheetName := range f.GetSheetMap() {
    		f.InsertRow(sheetName, 4)
    		f.InsertRow(sheetName, 5)
    		f.InsertRow(sheetName, 6)
    		f.InsertRow(sheetName, 7)
    	}
    
    	body := &bytes.Buffer{}
    	err = f.Write(body)
    	require.NoError(t, err)
    
    	d, _ := ioutil.ReadAll(body)
    
    	_ = ioutil.WriteFile("../../test_data/xlsx/result.xlsx", d, os.ModePerm)
    }
    

    sheet before test: before

    sheet after test: after

    Can you add adjusting pictures/drawings references?

    enhancement 
    opened by kjushka 0
  • Stream writer improvements - WIP

    Stream writer improvements - WIP

    PR Details

    Description

    • Adds SetPanes
    • Allows row widths to be changed after rows have already been written
    • Adds a way to use shared strings on stream mode

    Related Issue

    #1047

    Motivation and Context

    These changes make the stream mode more flexible, and will allow for things like autofilter to be implemented

    How Has This Been Tested

    For now I only tested generating large sheets with real world data I also looked at the xml and compared to another xml generated on normal mode Automated tests on the way

    Types of changes

    • [x] Docs change / refactoring / dependency upgrade
    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)

    Checklist

    • [ ] My code follows the code style of this project.
    • [x] My change requires a change to the documentation.
    • [x] I have updated the documentation accordingly.
    • [ ] I have read the CONTRIBUTING document.
    • [ ] I have added tests to cover my changes.
    • [ ] All new and existing tests passed.
    size/M 
    opened by harrison3000 0
  • feat:  StreamWriter supports []RichTextRun type value  as Cell value

    feat: StreamWriter supports []RichTextRun type value as Cell value

    PR Details

    stream writer support []RichTextRun as Cell value

    Description

    • write the []RichTextRun as sharedString
    • maintain the index

    Related Issue

    Motivation and Context

    rich text supported as cell value at the string writer context

    How Has This Been Tested

    TestStreamWriter executed

    Types of changes

    • [ ] Docs change / refactoring / dependency upgrade
    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)

    Checklist

    • [x] My code follows the code style of this project.
    • [ ] My change requires a change to the documentation.
    • [ ] I have updated the documentation accordingly.
    • [ ] I have read the CONTRIBUTING document.
    • [x] I have added tests to cover my changes.
    • [x] All new and existing tests passed.
    size/M 
    opened by carbin-gun 2
  • value from datetime format cell is wrong

    value from datetime format cell is wrong

    image image

    use GetRows function read value is 44087

    golang 16 excelize version: v2.5.0

    opened by dw130 5
  • How do I know the progress when I save a file

    How do I know the progress when I save a file

    if err := file.SaveAs("Book1.xlsx"); err != nil { fmt.Println(err) }

    opened by zmjaction 1
  • Exponential grown worktime of StreamWriter

    Exponential grown worktime of StreamWriter

    Description

    I use StreamWriter for generate large xlsx files. It's just text files: no formatting/styles.

    // about 100 columns with different data. But data size does not seriously matter in my tests
    dataRow := []interface{}{"Some", "Cell", "Values", "and 100 more"}
    
    // Do not check errors in issue
    excFile := excelize.NewFile()
    streamWriter, _ := excFile.NewStreamWriter("Sheet0")
    for rowNum := 1; rowNum < 50000; rowNum++ {
      streamWriter.SetRow("A"+strconv.Itoa(rowNum), dataRow)
    }
    
    streamWriter.Flush()
    file, _ := os.Create("some.xlsx")
    excFile.Write(file)
    

    In code example we create excel file with 50 000 rows with StreamWriter. All code will consume about 1.5 minute on my server. But if rows count increased to 100 000 in will consume not (2 * 1.5) min, but about 10 minutes. If there are million rows, it takes about 1.5 hours.

    Time increates not linear. Is there any way to make time more linear and speed up much rows creation?

    Output of go version:

    1.17.2
    

    Excelize version or commit ID:

    github.com/xuri/excelize/v2 v2.4.1
    

    Environment details (OS, Microsoft Excel™ version, physical, etc.): Ubuntu x86_64 with SSD drive.

    opened by IAkumaI 1
  • Is module path changing?

    Is module path changing?

    Description

    The repository is now at https://github.com/qax-os/excelize/ But go.mod still says: github.com/xuri/excelize/v2

    What is happening?

    opened by dolmen 4
  •  How to adjust the order of sheets?

    How to adjust the order of sheets?

    Adjust Sheet2 before Sheet1

    opened by iseejustdoit 1
  • Temp files created at /tmp are not cleaned up

    Temp files created at /tmp are not cleaned up

    I am using excelize to read a bunch of xls/xlsx files.

    Following is the outline of the usage,

    f, err := excelize.OpenFile("Book1.xlsx") if err != nil { return }

    rows, err := f.GetRows("Sheet1") if err != nil { fmt.Println(err) return }

    for _, row := range rows { for _, colCell := range row { fmt.Print(colCell, "\t") } fmt.Println() if break; }

    Issue Observed: During reading of the files some temporary files are created like, excelize-1448635484 at the following path, /tmp/ and never gets cleaned up. This is leading to eating up the memory of system causing more problems.

    Go Version: 1.16

    Excelize Version: 2.4.1

    Can someone please share us some insight on what is causing the temp file creations and what is preventing from the same being cleared.?

    needs more info 
    opened by sandeepatil1288 5
Releases(v2.5.0)
  • v2.5.0(Jan 2, 2022)

    We are pleased to announce the release of version 2.5.0. Featured are a handful of new areas of functionality and numerous bug fixes.

    A summary of changes is available in the Release Notes. A full list of changes is available in the changelog.

    Release Notes

    The most notable changes in this release are:

    Compatibility

    • Close spreadsheet and row's iterator required, the user should be close the stream after using the row's iterator, and close the spreadsheet after opening an existing spreadsheet
    • Change ReadZipReader as an implementation of the File, extract spreadsheet with given options, and support extract in memory or touching the filesystem
    • Remove unnecessary exported variable XMLHeader, we can using encoding/xml package's xml.Header instead of it
    • Remove unused exported error variable ErrToExcelTime

    Notable Features

    • New API: SetRowStyle support for set style for the rows, related issue #990
    • New API: GetCellType support for get the cell's data type, related issue #417 and #520
    • New API: SetAppProps and GetAppProps support to set and get document application properites, related issue #1095
    • GetCellValue, GetRows, GetCols, Rows and Cols support to specify read cell with raw value, related issue #621
    • New support 95 formula functions: ACCRINT, ACCRINTM, ADDRESS, AMORDEGRC, AMORLINC, AVEDEV, AVERAGEIF, CHIDIST, CONFIDENCE, CONFIDENCE.NORM, COUNTIF, COUNTIFS, COUPDAYBS, COUPDAYS, COUPDAYSNC, COUPNCD, COUPNUM, COUPPCD, DATEVALUE, DAY, DAYS, DELTA, DEVSQ, DISC, DURATION, ERF, ERF.PRECISE, ERFC, ERFC.PRECISE, GEOMEAN, GESTEP, IFNA, IFS, INDEX, INTRATE, ISFORMULA, ISLOGICAL, ISREF, ISOWEEKNUM, MATCH, MAXA, MAXIFS, MDURATION, MINIFS, MINUTE, MONTH, ODDFPRICE, PERCENTILE.EXC, PERCENTRANK.EXC, PERCENTRANK.INC, PERCENTRANK, PRICE, PRICEDISC, PRICEMAT, PV, QUARTILE.EXC, RANK, RANK.EQ, RATE, RECEIVED, RRI, SHEETS, SLN, STANDARDIZE, STDEV.P, STDEVP, SWITCH, SYD, TBILLEQ, TBILLPRICE, TBILLYIELD, TEXTJOIN, TIME, TRANSPOSE, TRIMMEAN, VALUE, VAR, VAR.S, VARA, VARPA, VDB, WEEKDAY, WEIBULL, WEIBULL.DIST, XIRR, XLOOKUP, XNPV, XOR, YEAR, YEARFRAC, YIELD, YIELDDISC, YIELDMAT, Z.TEST, ZTEST, related issue #1002
    • Formula calculation engine support nested calc for IF formula, related issue #987
    • Formula calculation engine support get shared formula, related issue #844
    • Formula calculation engine support text comparison, related issue #998
    • Support specify the formula in the data validation range, related issue #1012
    • Support specified unzip size limit on open file options, avoid zip bombs vulnerability attack
    • SetCellFormula now support set the shared formula
    • UpdateLinkedValue will skip macro sheet, related issue #1014
    • Fix AddPicture created duplicate image in some cases, caused by incorrect internal relationships ID calculation, related issue #1017
    • AddShape support set line width of add the shape, related issue #262
    • New options UnzipXMLSizeLimit have been added, support to specifies the memory limit on unzipping worksheet and shared string table in bytes
    • An error will be returned if given an invalid custom number format when creating a new style, related issue #1028
    • Now support set row style in the stream writer
    • Stream writer will create a time number format for time type cells, related issue #1107
    • Now support specify compact and outline for the pivot table, related issue #1029
    • Support get current rows/columns and total rows/columns in the stream reader, related PR #1054
    • Now support time zone location when set cell value, related issue #1069
    • Export 7 errors so users can act differently on different type of errors

    Improve the Compatibility

    • Improve compatibility with row element with r="0" attribute
    • Preserve XML control character
    • Improve the compatibility of style settings with Apple Numbers, related issue #1059
    • Support multi-byte language on set header footer, related issue #1061
    • Preserve horizontal tab character when set the cell value, related issue #1108

    Bug Fixes

    • Fix the data validation deletion failed, resolve issue #979
    • Fix set data validation drop list failed in some cases, resolve issue #986
    • Fix formula calculation engine LOOKUP doesn't handle array form correctly, resolve issue #994
    • Fix formula calculation engine LOOKUP can only find exact match, resolve issue #997
    • Fix formula percentages calculated incorrectly, resolve issue #993
    • Fix panic caused by incorrect cell read on some case
    • Fix conditional format bottom N not working
    • Fix time parse accuracy issue, resolve issue #1026 and #1030
    • Fix build-in scientific number format failed, resolve issue #1027
    • Fix small float parse error in some case, resolve issue #1031
    • Fix worksheet deletion failed in some case
    • Fix build-in time number format parse error, resolve issue #1060
    • Fix NewStyle returned incorrect style ID in some case
    • Fix merged cell range error after row/column insert/deletion in some corner case

    Performance

    • Merge cell time cost speed up, time cost decrease over 90%
    • Improve streaming reading performance, unzip shared string table to system temporary file when large inner XML, memory usage decreased about 60%, related issue #1096
    • Worksheet list read speed up
    • Merge column styles to reduce spreadsheet size, resolve issue #1057

    Miscellaneous

    • The dependencies module has been updated
    • Unit tests and godoc updated
    • Documentation website with multilingual: Arabic, German, Spanish, English, French, Russian, Chinese, Japanese, and Korean, which has been updated
    Source code(tar.gz)
    Source code(zip)
  • v2.4.1(Aug 1, 2021)

    We are pleased to announce the release of version 2.4.1. Featured are a handful of new areas of functionality and numerous bug fixes.

    A summary of changes is available in the Release Notes. A full list of changes is available in the changelog.

    Release Notes

    The most notable changes in this release are:

    Compatibility

    Change Go Modules import path to github.com/xuri/excelize/v2

    Notable Features

    • Support set column width in streaming mode, related issue #625
    • Support merge cell in streaming mode, related issue #826
    • New support 2 formula functions: BESSELK, BESSELY
    • The formula calculation engine now supports defined name references
    • Add disable option for chart xAxis and yAxis
    • The function AddPivotTable support reference source data range by defined name, relate issue #856
    • The following function now is concurrency safety, relate issue #861
    • Export 24 function's error message

    Improve the Compatibility

    • Improves compatibility for default XML namespace attributes, fix generated corrupted file in some case
    • Improves compatibility with non-standard page setup attributes, fix open spreadsheet failed in some case
    • Add count attribute in shared strings table
    • Remove UTC timezone requirement when setting cell value with time, related issue #409
    • Improves compatibility with XML control character in the escape literal string
    • Rename exported field File.XLSX to File.Pkg
    • Change the sheet names are not case sensitive for NewSheet, GetSheetIndex, DeleteSheet, resolve issue #873
    • Fix missing pivot attribute of conditional formatting, resolve issue #883
    • Improvement compatibility with invalid first-page number attribute in the page layout
    • Add maximum character limit and fix missing preserve character for SetCellRichText

    Bug Fixes

    • Fix 12/24 hours time format parsing error, resolve issue #823 and #841
    • Fix can't get comments by GetComments in some case, resolve issue #825
    • Fix issue when get and add comments on multi authors, resolve issue #829 and #830
    • Fix invalid file path and duplicate namespace when re-creating worksheet, resolve issue #834
    • Fix set outline attributes not work when the value of showOutlineSymbols, summaryBelow and summaryRight attributes are false
    • Avoid empty rows in the tail of the worksheet by GetRows, resolve issue #842
    • Fix missing formula cell when getting rows value, resolve issue #855
    • Fix comparison fails inside and outside IF function, resolve issue #858
    • Fix GetRowHeight actually get the height of the next row
    • Fix incorrect scope when getting and delete the defined name, resolve issue #879
    • Attribute LocalSheetID in the defined name should be equal to SheetIndex instead of SheetID
    • Fix missing set each cell's styles when set columns style, resolve issue #467
    • Prevent panic when an incorrect range is provided as PivotTableRange on creating a pivot table
    • Fix reading decimals precision issue, resolve issue #848 and #852
    • Escape XML character in the drop list, avoid corrupted file generated, resolve issue #971
    • Fix incorrect character count limit in the drop list, resolve issue #972
    • Fix high CPU usage on reading cell value with number format caused by Excel time parse issue in some case, resolve issue #974
    • Fix month parsing error in custom number format in some cases

    Performance

    • Reduce redundant memory on Save and SaveAs about 19%

    Miscellaneous

    • Fix code security issue CWE-190 and CWE-681
    • The dependencies module has been updated
    • Unit tests and godoc updated
    • Use GitHub Action for unit testing
    • Documentation website with multilingual: Arabic, German, Spanish, English, French, Russian, Chinese, Japanese, and Korean, which has been updated
    Source code(tar.gz)
    Source code(zip)
  • v2.4.0(Apr 18, 2021)

    We are pleased to announce the release of version 2.4.0. Featured are a handful of new areas of functionality and numerous bug fixes.

    A summary of changes is available in the Release Notes. A full list of changes is available in the changelog.

    Release Notes

    The most notable changes in this release are:

    Compatibility

    Upgrade requirements Go language version is 1.15 or later.

    Notable Features

    • New API GetCellRichText support to get the rich text of cell by given worksheet
    • Now support to set and get: print scaling, print black and white, and specified the first printed page number of the worksheet by SetPageLayout and GetPageLayout
    • Now support to change and get tab color of the worksheet by SetSheetPrOptions and GetSheetPrOptions
    • SetCellHyperlink now support to set hyperlink display & tooltips text, related issue #790
    • Support ShowError option when adding the pivot table
    • Support setting formula for cell in streaming API, related issue #625
    • The formula calculation engine now supports not equal operator
    • The nested formula function now supports cell references as arguments
    • Support to specifies that each data marker in the series has a different color
    • New support 152 formula functions: ATAN, AVERAGE, AVERAGEA, BESSELI, BESSELJ, BIN2DEC, BIN2HEX, BIN2OCT, BITAND, BITLSHIFT, BITOR, BITRSHIFT, BITXOR, CHAR, CHOOSE, CLEAN, CODE, COLUMN, COLUMNS, COMPLEX, CONCAT, CONCATENATE, COUNT, COUNTBLANK, CUMIPMT, CUMPRINC, DATE, DATEDIF, DB, DDB, DEC2BIN, DEC2HEX, DEC2OCT, DOLLARDE, DOLLARFR, EFFECT, ENCODEURL, EXACT, FALSE, FIND, FINDB, FISHER, FISHERINV, FIXED, FV, FVSCHEDULE, GAMMA, GAMMALN, HARMEAN, HEX2BIN, HEX2DEC, HEX2OCT, HLOOKUP, IF, IFERROR, IMABS, IMAGINARY, IMARGUMENT, IMCONJUGATE, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMDIV, IMEXP, IMLN, IMLOG10, IMLOG2, IMPOWER, IMPRODUCT, IMREAL, IMSEC, IMSECH, IMSIN, IMSINH, IMSQRT, IMSUB, IMSUM, IMTAN, IPMT, IRR, ISTEXT, ISPMT, KURT, LARGE, LEFT, LEFTB, LEN, LENB, LOOKUP, LOWER, MAX, MID, MIDB, MIN, MINA, MIRR, N, NOMINAL, NORM.DIST, NORMDIST, NORM.INV, NORMINV, NORM.S.DIST, NORMSDIST, NORM.S.INV, NORMSINV, NOT, NOW, NPER, NPV, OCT2BIN, OCT2DEC, OCT2HEX, PDURATION, PERCENTILE.INC, PERCENTILE, PERMUT, PERMUTATIONA, PMT, POISSON.DIST, POISSON, PPMT, PROPER, QUARTILE, QUARTILE.INC, REPLACE, REPLACEB, REPT, RIGHT, RIGHTB, ROMAN, ROW, ROWS, SHEET, SKEW, SMALL, STDEV, STDEV.S, STDEVA, SUBSTITUTE, T, TODAY, TRIM, TRUE, UNICHAR, UNICODE, UPPER, VAR.P, VARP, VLOOKUP

    Improve the Compatibility

    • Now set the empty string for the cell when SetCellValue with nil, resolve issue #756
    • Remove useless internal XML omitempty tag on style pattern fill color
    • Fix compatibility issue of Google Sheets offline browser extension #769
    • Use absolute reference in the auto filters defined name to make it compatible with OpenOffice, resolve issue #776
    • Handle end element event in the worksheet row/column iterator XML SAX parser, faster row/column iterate and fix inconsistent read rows count of the file in some case
    • Improves compatibility for worksheet relative XML path
    • Avoid duplicate rich text string items #787
    • Improves compatibility for absolute XML path, Windows-style directory separator, and inline namespace

    Bug Fixes

    • Fix round precision issue #764
    • Add missing fields and change the order of the fields of workbook fields, prevent generate the corrupted file in some case, resolve issue #766
    • Fix hyperbolic cotangent calculation incorrect
    • Correct adjust calculation chain in duplicate rows, resolve issue #774
    • Correct adjust defined name in the workbook when deleting a worksheet, resolve issue #775
    • Fix cyclomatic complexity issue of internal function newFills and parseToken
    • Fix custom row height check issue
    • Fix unmerge all cells cause corrupted file, resolve issue #782
    • Fix part of auto filter rules missing after saved
    • Fix UpdateLinkedValue which returns an error when has chart sheet or dialog sheet
    • Fix incorrect default column from GetColWidth in some case
    • Fix can't add timelines and slicers for a pivot table in a generated spreadsheet, resolve issue #804
    • Fix incorrect SetDefinedName's localSheetId attribute to use sheetIndex
    • Fix missing cell locked or hidden protection in some case, resolve issue #809
    • Fix streaming data writer result missing after call normal API, resolve issue #813
    • Fix the negative values series missing chart color issue

    Performance

    • Faster numeric precision process

    Miscellaneous

    • The dependencies module has been updated
    • Unit tests and godoc updated
    • Documentation website with multilingual: Arabic, German, Spanish, English, French, Russian, Chinese, Japanese, and Korean, which has been updated
    • Welcome join the Slack channel or Telegram Group to meet other members of our community
    Source code(tar.gz)
    Source code(zip)
  • v2.3.2(Jan 3, 2021)

    We are pleased to announce the release of version 2.3.2. Featured are a handful of new areas of functionality and numerous bug fixes.

    A summary of changes is available in the Release Notes. A full list of changes is available in the changelog.

    Release Notes

    The most notable changes in this release are:

    Notable Features

    • The function AddPivotTable now support none-column and multi-data fields, relate issue #710
    • The function GetCellValue support custom date-time number format, relate issue #703
    • The function CalcCellValue now support new formula function AND, CLEAN, TRIM, LOWER, PROPER, UPPER and OR, relate issue #701 and #747
    • The range of data validation now supports float decimal, relate issue #739
    • The function AddChart now support to set marker type and custom line width, relate issue #549 and #657

    Improve the Compatibility

    • Improve over 6 series line chart compatibility with KingSoft WPS™, resolve #627
    • Avoid creating duplicate inner style in some case
    • Parse document core part (workbook) dynamically
    • Support single line with repeated row element in the worksheet data, resolve #732

    Bug Fixes

    • Prevent formula lexer panic on retrieving the top token type on some invalid formula, resolve issue #711
    • Fix missing worksheet when renaming with same names, resolve issue #713
    • Fix wrong worksheet index returned by NewSheet in some cases, resolve issue #714
    • Fix panic on formatted value with no built-in number format ID, resolve issue #715 and #741
    • Rounding numeric with precision for formula calculation, resolve issue #727
    • Fix row duplicate mechanism #729
    • Fix incorrect active tab after delete worksheet in some cases, resolve issue #735
    • Fix AddPicture autofit failure with multi merged cells, resolve issue #748

    Performance

    • Stream writing memory usage decrease about 60%, relate issue #659
    • Optimize memory allocation workSheetWriter, relate issue #722
    • Improve AddPicture performance, relate issue #706

    Miscellaneous

    • Unit tests and godoc updated
    • Documentation website with multilingual: English, French, Russian, Chinese, Japanese, and Korean, which has been updated, 3 new language: Arabic, German and Spanish language version docs published
    • Welcome join the Slack channel or Telegram Group to meet other members of our community
    Source code(tar.gz)
    Source code(zip)
  • v2.3.1(Sep 22, 2020)

    We are pleased to announce the release of version 2.3.1. Featured are a handful of new areas of functionality and numerous bug fixes.

    A summary of changes is available in the Release Notes. A full list of changes is available in the changelog.

    Release Notes

    The most notable changes in this release are:

    Notable Features

    • Support open spreadsheet with password protection by ECMA-376 document standard encryption, relate issue #199
    • Add checking and limits for the worksheet
    • Extend pivot table functionality: support set the header, style, and table options for the pivot table
    • Security vulnerabilities and patches

    Improve the Compatibility

    • Compatible with Go 1.15, fix unit test failed on Windows and potential race condition, relate issue #689
    • Default row height compatibility with Apache OpenOffice and Kingsoft WPS™
    • Improve compatibility for the phonetic hint and sheet tab color

    Bug Fixes

    • Fix RemoveRow slice bounds out of range cause panic in some case, resolve #686
    • Fix stream writer generated corrupted files issue
    • Fix the scale for add picture not work, resolve #691

    Miscellaneous

    • Unit tests update and typo fixed
    • Documentation website with multilingual: English, French, Russian, Chinese, Japanese, and Korean, which has been updated
    • Welcome join the Slack channel to meet other members of our community
    Source code(tar.gz)
    Source code(zip)
  • v2.3.0(Aug 9, 2020)

    We are pleased to announce the release of version 2.3.0. Featured are a handful of new areas of functionality and numerous bug fixes.

    A summary of changes is available in the Release Notes. A full list of changes is available in the changelog.

    Release Notes

    The most notable changes in this release are:

    Notable Features

    • Support to set cell values concurrent, relate issue #670
    • New API: SetSheetFormatPr and GetSheetFormatPr, support to set and get worksheet formatting properties, relate issue #635
    • New API: GetCols and Cols, support columns iterator
    • AddChart support specified logarithmic scale on Y-axis, relate issue #661
    • AddPicture support insert image autofit cell
    • Add limits for total columns, row and filename length
    • Formula calculation engine support defined name, relate issue #665
    • API CalcCellValue update, formula calculation engine working in progress: 12 new functions has been added, COUNTA, ISBLANK, ISERR, ISERROR, ISEVEN, ISNA, ISNONTEXT, ISODD, ISNUMBER, MEDIAN, NA, SUMIF

    Improve the Compatibility

    • Compatible to case-sensitive doc parts path
    • Storage string to SST (shared string table), relate issue #622
    • Support the row element without r attribute in the worksheet
    • Support XML multi namespace, make compatible with Kingsoft WPS™ Office, relate issue #651
    • Improve the compatibility of the auto filter with Office 2007 - 2010, resolve #637

    Bug Fixes

    • Avoid duplicate filter database in workbook defined name
    • Avoid creating duplicate style, resolve #643
    • Escape characters for set rich-text
    • Fix the issue, comment shapes are changed after reopening spreadsheet created by Excelize, resolve #672
    • Fix panic when enabling compiler inline flags, resolve #677 and #679
    • Fix the accuracy issue of getting cell value of percentage cell

    Miscellaneous

    • Improved error handling and fix crash when open invalid spreadsheet file
    • Add missing checking error in unit tests
    • Documentation website with multilingual: English, French, Russian, Chinese, Japanese, and Korean, which has been updated
    Source code(tar.gz)
    Source code(zip)
  • v2.2.0(May 10, 2020)

    We are pleased to announce the release of version 2.2.0. Featured are a handful of new areas of functionality and numerous bug fixes.

    A summary of changes is available in the Release Notes. A full list of changes is available in the changelog.

    Release Notes

    The most notable changes in this release are:

    Notable Features

    • Using the worksheet index instead of ID in the following functions: GetSheetName, GetSheetIndex, GetActiveSheetIndex and SetActiveSheet, relate issue #485
    • New function GetSheetList to get the worksheet, chart sheet, and dialog sheet name list of the workbook
    • New function AddChartSheet support create chart sheet, relate issue #451
    • New function UnsetConditionalFormat, support for remove conditional format, relate issue #571
    • New function DeleteDataValidation, support delete data validation, relate issue #348
    • New function SetCellRichText, support set rich text, relate issue #172
    • New functions InsertPageBreak and RemovePageBreak, support for insert and remove page break, relate issue #492
    • The AddPivotTable API changed, support for setting date field subtotal and names of the pivot table, relate issue #582
    • The AddPivotTable support to set the filter for the pivot table, relate issue #598
    • The AddPivotTable allow empty filter, data, and rows in the pivot table
    • Export ExcelDateToTime function to convert excel date to time
    • Export Style structs to allow create the style for cells by given JSON or structure pointer, relate issue #470

    Bug Fixes

    • Fix greaterThanOrEqual and lessThanOrEqual operators did not work when setting the conditional format for cell by SetConditionalFormat, resolve issue #608
    • Fix corrupt worksheet created by StreamWriter, resolve issue #576
    • Escape character in the formula, resolve issue #578
    • Fix the DuplicateRowTo function doesn't duplicate merged cells, resolve issue #586
    • Fix conditional formatting hides the adjacent borders by ignoring empty conditional format style, resolve issue #200
    • Fix missing comments by GetComments, resolve issue #345
    • Fix reading wrong string by GetCellValue in some case, resolve issue #602
    • Check and fill the cell without r attribute in a row element, fix returned empty value when GetCellValue in some case
    • Allow empty or default cell style formats, resolve #628

    Performance

    • Reduce redundant memory copy in getRowHeight

    Miscellaneous

    • Remove calculated properties to make recalculate formulas in some spreadsheet applications, such as Kingsoft WPS™ Office
    • Add missing checking error in unit tests
    • Documentation website with multilingual: English, French, Russian, Chinese, Japanese, and Korean, which has been updated
    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Feb 9, 2020)

    We are pleased to announce the release of version 2.1.0. Featured are a handful of new areas of functionality and numerous bug fixes.

    A summary of changes is available in the Release Notes. A full list of changes is available in the changelog.

    Release Notes

    The most notable changes in this release are:

    Notable Features

    • New function DeleteDefinedName, support to delete the defined names of the workbook or worksheet
    • New functions SetPageMargins and GetPageMargins, support to for getting setting page margins
    • New functions DeleteChart and DeletePicture, support to delete chart and images from the worksheet
    • Add support for Excel file that uses no UTF-8 encoding
    • The function AddChart now support to create the pie of pie chart, the bar of pie chart and combo chart The function AddChart now support to set minor grid lines for the chart, relate issue #501 The function AddChart now support to set line width of the line chart, relate issue #505 The function AddChart now support to set a major unit and tick label skip for the chart, relate issue #538
    • The function SetColVisible now support to set column visible by column range
    • The function AddPivotTable allow empty columns in the pivot table, relate issue #511

    Bug Fixes

    • Fix missing ending space text of the cell
    • The MergeCell function support overlapped merge cells, resolve issue #533
    • Added handling of empty inline rich text in some case, resolve issue #529
    • Added handling of empty workbook view in some case, resolve issue #426
    • Added handling of escape character in the formula, resolve issue #546

    Performance

    • New functions NewStreamWriter and Flush to generate the new worksheet with huge amounts of data. Compared to non-streaming writing, reduced memory usage by 90.2%, time cost by 53%
    • Make GetRows function read data as streaming. Reduced memory usage by 78.9%, relate issues #146 and #382
    • Compatibility improvements, adding 49 internal XML namespaces support

    Miscellaneous

    • Added logging of possible errors when decoding XML, relate issues #539
    • Improve code coverage unit tests (line Coverage: 97.04%)
    • Add missing checking error in unit tests
    • Documentation website with multilingual: English, French, Russian, Chinese, Japanese, and Korean, which has been updated
    Source code(tar.gz)
    Source code(zip)
  • v2.0.2(Oct 9, 2019)

    We are pleased to announce the release of version 2.0.2. Featured are a handful of new areas of functionality and numerous bug fixes.

    A summary of changes is available in the Release Notes. A full list of changes is available in the change log.

    Release Notes

    The most notable changes in this release are:

    Compatibility

    Upgrade requirements Go language version is 1.10 or later.

    Notable Features

    • Create pivot table support. New function AddPivotTable() has been added
    • Create sparkline support. New function AddSparkline() has been added
    • New function GroupSheets() and UngroupSheets() support group and ungroup sheets
    • New function AddVBAProject() to support add vbaProject.bin file which contains functions and/or macros
    • The function SetPageLayout() now support to support to set fit to width and height, relate issue #432
    • The function SetSheetViewOptions() support to set whether to "show a zero in cells that have zero value" now
    • Allow access to more formula attributes in SetCellFormula(), support set the type of the formula and the ref attribute
    • Font strike style support, relate issue #482

    Bug Fixes

    • Fix missing text of comments in some case, resolve issue #434
    • Fix RemoveRow() out of range in some case by recalculate offset for merged cells adjuster, resolve issue #437
    • Fix invalid formula in data validation drop list
    • Fix file corrupted when calling the Save() method in the iteration, resolve issue #443
    • Compatible with different types of relative paths in workbook.xml.rels to fix read file failed in some case, resolve issue #442
    • Fixed file corruption when deleting all merged cells in some case
    • Fix issue where the protection worksheet settings are invalid in some case, resolve issue #454
    • Fix GetSheetName doesn't work in some case by check the sheets list based on index instead, resolve issue #457
    • Add multi-row inline strings support, relate issue #464
    • Fix overflow numeric cell value on the 32-bit operating system, relate issue #386
    • Fix go module dependency errors, relate issue #466 and #480
    • Fix file corrupted when calling SetSheetPrOptions() in some case, resolve issue #483

    Performance

    • Performance optimization, faster for reading the file, relate issue #439

    Miscellaneous

    • Add missing error check in SetSheetRow()
    • Optimize code, combine internal functions: workBookRelsWriter, drawingRelsWriter into relsWriter; drawingRelsReader, workbookRelsReader, workSheetRelsReader into relsReader addDrawingRelationships, addSheetRelationships into addRels
    Source code(tar.gz)
    Source code(zip)
  • v2.0.1(Jun 30, 2019)

    We are pleased to announce the release of version 2.0.1. Featured are a handful of new areas of functionality and numerous bug fixes.

    A summary of changes is available in the Release Notes. A full list of changes is available in the change log.

    Release Notes

    The most notable changes in this release are:

    Notable Features

    • New function SetHeaderFooter() init set header and footer support, relate issue #394
    • New function SetColStyle() support to set style by columns, relate issue #397
    • New functions SetDefaultFont() and GetDefaultFont() support to change the default font, relate issue #390
    • New functions SetDocProps() and GetDocProps(), support to set and get doc properties, relate issue #415
    • The function AddChart() now support to create new 26 types of chart: cone, pyramid and cylinder series chart for column and bar, surface 3D, wireframe Surface 3D, contour and wireframe contour,bubble and a 3D bubble chart, unsupported chart type add error prompt
    • New functions SetDefinedName() and GetDefinedName() support to set and get defined names
    • More detailed error information when open the encrypted file
    • The function AddPicture() now support to add TIF and TIFF format images

    Bug Fixes

    • Fix structs fields definition errors and keep double quotes in data validation formula
    • Fix comments duplicate caused by inner counting errors, resolve issue #373
    • Fix read file error caused by getting sheet map errors, resolve issue #404
    • Enhance compatibility with PivotTable, resolve issue #413
    • Enhance compatibility with font size and a bold style, resolve issue #411, #420, and #425
    • Enhance recalculation adjuster to resolve file broken issue, after insert or remove rows in some case, relate issue #421 and #424
    • Fix hide sheet does not work in some case, relate issue #418
    • Fix multi-chart series caused file corrupted by avoid accent theme color index overflow, relate issue #422

    Miscellaneous

    • Improve unit testing coverage (Line Coverage: 96.05%)
    • Optimize code, fix golint issues
    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(May 2, 2019)

    We are pleased to announce the release of version 2.0.0. Featured are a handful of new areas of functionality and numerous bug fixes.

    A summary of changes is available in the Release Notes. A full list of changes is available in the change log.

    Release Notes

    The most notable changes in this release are:

    API Changed

    The following table lists the changes to the API for v2.0.0 compared to the v1.4.1:

    |Function|Add error return|Row Number Change*|Delete|New Addition| |---|---|---|---|---| |ToALphaString|×|×|√|×| |TitleToNumber|×|×|√|×| |SplitCellName|×|×|×|√| |JoinCellName|×|×|×|√| |ColumnNameToNumber|×|×|×|√| |ColumnNumberToName|×|×|×|√| |CellNameToCoordinates|×|×|×|√| |CoordinatesToCellName|×|×|×|√| |SetCellFloat|×|×|×|√| |SetCellStyle|√|×|×|×| |InsertCol|√|×|×|×| |RemoveCol|√|×|×|×| |RemoveRow|√|√|×|×| |InsertRow|√|√|×|×| |DuplicateRow|√|×|×|×| |DuplicateRowTo|√|×|×|×| |SetRowHeight|√|×|×|×| |GetRowHeight|√|×|×|×| |GetCellValue|√|×|×|×| |GetCellFormula|√|×|×|×| |GetCellHyperLink|√|×|×|×| |SetCellHyperLink|√|×|×|×| |SetCellInt|√|×|×|×| |SetCellBool|√|×|×|×| |SetCellStr|√|×|×|×| |SetCellDefault|√|×|×|×| |GetCellStyle|√|×|×|×| |SetCellValue|√|×|×|×| |MergeCell|√|×|×|×| |SetSheetRow|√|×|×|×| |SetRowVisible|√|√|×|×| |GetRowVisible|√|√|×|×| |SetRowOutlineLevel|√|√|×|×| |GetRowOutlineLevel|√|√|×|×| |GetRows|√|×|×|×| |Columns|√|×|×|×| |SearchSheet|√|×|×|×| |GetPicture|√|×|×|×| |GetColVisible|√|×|×|×| |SetColVisible|√|×|×|×| |GetColOutlineLevel|√|×|×|×| |SetColOutlineLevel|√|×|×|×| |SetColWidth|√|×|×|×| |GetColWidth|√|×|×|×| |GetMergeCells|√|×|×|×| |ProtectSheet|√|×|×|×| |UnprotectSheet|√|×|×|×| |UpdateLinkedValue|√|×|×|×| |SetSheetVisible|√|×|×|×| |adjustHelper|√|×|×|×| |adjustMergeCells|√|×|×|×| |adjustAutoFilter|√|×|×|×| |prepareCell|√|×|×|×| |setDefaultTimeStyle|√|×|×|×| |timeToExcelTime|√|×|×|×| |addDrawingChart|√|×|×|×| |addDrawingVML|√|×|×|×| |addDrawingPicture|√|×|×|×| |getTotalRowsCols|√|×|×|×| |checkRow|√|×|×|×| |addDrawingShape|√|×|×|×| |addTable|√|×|×|×| |workSheetReader|√|×|×|×| |copySheet|√|×|×|×|

    * From version 2.0.0 all row manipulation methods use Excel row numbering starting with 1 instead of zero-based numbering which takes place in some methods in earlier versions, related issue #349.

    Notable Features

    • New function DuplicateRowTo() has been added for duplicate row to specified row position
    • The function SetPageLayout() now support to set page orientation, related issue #318
    • The function SetPageLayout() now support to set page size

    Bug Fixes

    • Fix the issue that creates a blank fill if no fill is specified in the style format
    • Fix the issue that data validation list in the excel sheet disappears formula characters greater than 255, related issue #339
    • Fix the issue corrupted spreadsheet file after deleting formula of the cell, related issue #346
    • Fix the issue that GetComment() returns incorrect mapping between worksheets and comments in some case, related issue #345
    • Fix the issue #346, resolve the issue corrupted spreadsheet file after deleting formula of cell
    • Fix the issue #377, avoid empty column in GetRows result

    Performance

    • Performance optimization, faster for adding comments, related issue #347, faster add images, charts, and shapes, related issue #274
    • Adding the same image should create a drawing referencing the already stored copy of the image, related issue #359
    Excelize v1.4.1 VS v2.0.0

    Miscellaneous

    • Typo fixed and godoc updated
    • Tests made stronger again, go1.12 added to tests matrix
    Source code(tar.gz)
    Source code(zip)
  • v1.4.1(Jan 3, 2019)

    We are pleased to announce the release of version 1.4.1. Featured are a handful of new areas of functionality and numerous bug fixes.

    A summary of changes is available in the Release Notes. A full list of changes is available in the change log.

    Release Notes

    The most notable changes in this release are:

    Notable Features

    • New function WriteTo() has been added, it implements io.WriterTo to write the file
    • New function SearchSheet() has been added to get coordinates by given worksheet name, cell value, and regular expression. Relate issue #277
    • New functions ProtectSheet() and UnprotectSheet() has been added to prevent other users from accidentally or deliberately changing, moving, or deleting data in a worksheet, relate issue #273
    • New functions GetMergeCells() has been added, support to get all merged cells from a worksheet currently
    • Add support to flip outline summaries, relate issue #304
    • Support go module
    • Support set and get TopLeftCell properties of sheet view options, relate issue #310
    • The function AddChart() now support to create 2D / 3D area, stacked area, 100% stacked area charts, relate issue #311

    Bug Fixes

    • Fix the issue caused by missing tradition to strict conversion for sharedStringsReader(), resolve issue #276
    • Fix unknown option in chart format JSON struct tag
    • Fix nil pointer dereference when getting cell formula in some case, resolve issue #290
    • Make the function GetRows() return value avoid empty rows in the tail of the worksheet, resolve issue #195
    • Fix GetSheetMap() failed in some case, resolve issue #297
    • Fix delete worksheet index error in some case, resolve issue #308

    Miscellaneous

    • Tests refactoring, resolve issue #322
    • Add a new logo for excelize, numerous documentation updates
    Source code(tar.gz)
    Source code(zip)
  • v1.4.0(Sep 27, 2018)

    We are pleased to announce the release of 1.4.0.

    Release Notes

    The most notable changes in this release are:

    API Changed

    • Add error return value for functions: AddChart(), AddComment(), AddPicture(), AddShape(), AddTable() and SetConditionalFormat()

    Notable Features

    Bug Fixes

    • Improved commenting formatting, fix expands all comment boxes stacked all in one place
    • Fix create worksheet by NewSheet() cause file issue, related issue #249

    Performance

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Jun 11, 2018)

    We are pleased to announce the release of v1.1.0.

    Release Notes

    The most notable changes in this release are:

    • Feature: Conditional format support
    • Count and trim sheet name in UTF-8
    • Bugfix: deep copy issue with function CopySheet()
    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Jun 11, 2018)

    We are pleased to announce the release of 1.2.0.

    Release Notes

    The most notable changes in this release are:

    • Performance optimization
    • Improvement Golang 1.9 compatibility
    • Stacked bar chart supported
    • 24-hour time format supported
    • API changed, use worksheet name instead of "sheet" + index
    • Rename import path to github.com/360EntSecGroup-Skylar/excelize
    • Add new functions SetSheetViewOptions and GetSheetViewOptions
    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(May 13, 2018)

    We are pleased to announce the release of 1.3.0.

    Release Notes

    The most notable changes in this release are:

    API Changed

    • Make row index consistent in function SetRowHeight() and GetRowHeight(), fix issue #205

    Notable Features

    • New function SetSheetRow() has been added for support write the whole line at once, relate issue #96 and #194
    • New functions GetColOutlineLevel(), GetRowOutlineLevel(), SetColOutlineLevel() and SetRowOutlineLevel() has been added for suppport creat group
    • Add iterator method for Rows, new functions Columns(), Next() and Error() has been added
    • Function SetCellValue() now supports bool and time.Duration type value
    • Function AddTable() now supports set name of table, relate issue #216
    • Function AddPicture() now supports set the positioning of a picture, relate issue #214
    • Function GetCellValue() now supports read inlineStr type cell value, relate issue #208 and pull request #209
    • Function AddChart() now supports set custom chart size
    • Add 3D, 3D 100%, clustered, stacked and 100% stacked bar and column series charts supported, relate issue #160 and #190
    • Add a hyperlink to image support for the function AddPicture(), relate issue #185
    • Add protection properties associated with the cell support, relate issue #191
    • Add categories or values on reverse order (orientation of the chart) support, and set auto or fixed maximum, minimum of the axis, relate issue #202

    Bug Fixes

    • Fix DeleteSheet() make broken file caused by activeTab tag calculation wrong, relate issue #165
    • Fix read columns count wrong in specific worksheet data, relate issue #175
    • Handle special shared string table file name xl/SharedStrings.xml to make library compatibility with 1C software, relate issue #188
    • Fix checkCellInArea() index out of range when the merged cell reference is single coordinate, relate issue #206
    • Fix set font-family doesn't work, relate issue #222

    Performance

    • Make SetCellStyle() quicker by skipping conversions in checkCellInArea(), and skipping area checks when we are sure the cell can't be before or past the current row/col
    • Save bytes on memory instead of string, 11% memory savings, see Performance Figures
    Source code(tar.gz)
    Source code(zip)
Owner
QI-ANXIN GROUP
QI-ANXIN Open Source
QI-ANXIN GROUP
Go (golang) library for reading and writing XLSX files.

XLSX Introduction xlsx is a library to simplify reading and writing the XML format used by recent version of Microsoft Excel in Go programs. Tutorial

Geoffrey J. Teale 5.2k Jan 20, 2022
Pure go library for creating and processing Office Word (.docx), Excel (.xlsx) and Powerpoint (.pptx) documents

unioffice is a library for creation of Office Open XML documents (.docx, .xlsx and .pptx). Its goal is to be the most compatible and highest performan

UniDoc 3.1k Jan 16, 2022
Golang bindings for libxlsxwriter for writing XLSX files

goxlsxwriter provides Go bindings for the libxlsxwriter C library. Install goxlsxwriter requires the libxslxwriter library to be installe

Frank Terragna 17 Nov 12, 2021
Golang bindings for libxlsxwriter for writing XLSX files

goxlsxwriter goxlsxwriter provides Go bindings for the libxlsxwriter C library. Install goxlsxwriter requires the libxslxwriter library to be installe

Frank Terragna 730 May 30, 2021
A simple and light excel file reader to read a standard excel as a table faster | 一个轻量级的Excel数据读取库,用一种更`关系数据库`的方式解析Excel。

Intro | 简介 Expect to create a reader library to read relate-db-like excel easily. Just like read a config. This library can read all xlsx file correct

Back Yu 133 Jan 6, 2022
A simple excel engine without ui to parse .csv files.

A simple excel engine without ui to parse .csv files.

Akmal Hossain 1 Nov 4, 2021
go-eexcel implements encoding and decoding of XLSX like encoding/json

go-eexcel go-eexcel implements encoding and decoding of XLSX like encoding/json Usage func ExampleMarshal() { type st struct { Name string `eexce

sago35 0 Dec 9, 2021
A Go native tabular data extraction package. Currently supports .xls, .xlsx, .csv, .tsv formats.

grate A Go native tabular data extraction package. Currently supports .xls, .xlsx, .csv, .tsv formats. Why? Grate focuses on speed and stability first

Jeremy Jay 98 Nov 20, 2021
一款 Go 语言编写的小巧、简洁、快速采集 fofa 数据导出到 Excel 表单的小工具。

fofa 一款 Go 语言编写的小巧、简洁、快速采集 fofa 数据导出到 Excel 表单的小工具。 Goroutine + retryablehttp Build git clone https://github.com/inspiringz/fofa cd fofa go build -ldf

3ND 20 Jan 21, 2022
Fastq demultiplexer for single cell data from MGI sequencer (10x converted library).

fastq_demultiplexer Converts fastq single cell data from MGI (10x converted library) to Illumina compatible format. Installation go install github.com

Rostislav Vorobev 0 Nov 24, 2021
Golang library for reading and writing Microsoft Excel™ (XLSX) files.

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

360 Enterprise Security Group, Endpoint Security, inc. 10.7k Jan 21, 2022
Golang library for reading and writing Microsoft Excel™ (XLSX) files.

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

360 Enterprise Security Group, Endpoint Security, inc. 10.6k Jan 16, 2022
Fast and reliable way to work with Microsoft Excel™ [xlsx] files in Golang

Xlsx2Go package main import ( "github.com/plandem/xlsx" "github.com/plandem/xlsx/format/conditional" "github.com/plandem/xlsx/format/conditional/r

Andrey G. 146 Dec 13, 2021
Go (golang) library for reading and writing XLSX files.

XLSX Introduction xlsx is a library to simplify reading and writing the XML format used by recent version of Microsoft Excel in Go programs. Tutorial

Geoffrey J. Teale 5.2k Jan 16, 2022
Go (golang) library for reading and writing XLSX files.

XLSX Introduction xlsx is a library to simplify reading and writing the XML format used by recent version of Microsoft Excel in Go programs. Tutorial

Geoffrey J. Teale 5.2k Jan 20, 2022
Go (golang) library for reading and writing XLSX files.

XLSX Introduction xlsx is a library to simplify reading and writing the XML format used by recent version of Microsoft Excel in Go programs. Current s

Geoffrey J. Teale 5.2k Jan 16, 2022
Command-line tool to load csv and excel (xlsx) files and run sql commands

csv-sql supports loading and saving results as CSV and XLSX files with data processing with SQLite compatible sql commands including joins.

Dhamith Hewamullage 24 Sep 30, 2021
Pure go library for creating and processing Office Word (.docx), Excel (.xlsx) and Powerpoint (.pptx) documents

unioffice is a library for creation of Office Open XML documents (.docx, .xlsx and .pptx). Its goal is to be the most compatible and highest performan

UniDoc 3.1k Jan 16, 2022
golang 在线预览word,excel,pdf,MarkDown(Online Preview Word,Excel,PPT,PDF,Image by Golang)

Go View File 在线体验地址 http://39.97.98.75:8082/view/upload (不会经常更新,保留最基本的预览功能。服务器配置较低,如果出现链接超时请等待几秒刷新重试,或者换Chrome) 目前已经完成 docker部署 (不用为运行环境烦恼) Wor

CZC 42 Jan 6, 2022
Golang bindings for libxlsxwriter for writing XLSX files

goxlsxwriter provides Go bindings for the libxlsxwriter C library. Install goxlsxwriter requires the libxslxwriter library to be installe

Frank Terragna 17 Nov 12, 2021
Golang bindings for libxlsxwriter for writing XLSX files

goxlsxwriter goxlsxwriter provides Go bindings for the libxlsxwriter C library. Install goxlsxwriter requires the libxslxwriter library to be installe

Frank Terragna 730 May 30, 2021
A simple and light excel file reader to read a standard excel as a table faster | 一个轻量级的Excel数据读取库,用一种更`关系数据库`的方式解析Excel。

Intro | 简介 Expect to create a reader library to read relate-db-like excel easily. Just like read a config. This library can read all xlsx file correct

Back Yu 133 Jan 6, 2022
General purpose library for reading, writing and working with OpenStreetMap data

osm This package is a general purpose library for reading, writing and working with OpenStreetMap data in Go (golang). It has the ability to read OSM

Paul Mach 186 Jan 14, 2022
General purpose library for reading, writing and working with OpenStreetMap data

osm This package is a general purpose library for reading, writing and working with OpenStreetMap data in Go (golang). It has the ability to read OSM

Paul Mach 187 Jan 18, 2022
Package implement reading and writing popular playlist formats: PLS, ASX, M3U, XSPF and others.

go-playlist ⚠️ WARNING The API is not stable yet and can change. Package playlist implement reading and writing popular playlist formats: PLS, ASX, M3

Roman Kulish 0 Oct 14, 2021
Package raw enables reading and writing data at the device driver level for a network interface. MIT Licensed.

raw Package raw enables reading and writing data at the device driver level for a network interface. MIT Licensed. For more information about using ra

Matt Layher 414 Jan 11, 2022
A challenge in Go. A simple backend responding to API calls reading/writing data from to PostgreSQL db.

Go Challenge The challenge has been executed in two different steps. Steps 1 Hour tag: 1 hour: As the challenge required, the tag is a snapshot of wha

Sergio Maria Matone 0 Dec 4, 2021
Monkey programming language project from 'Writing An Interpreter In Go'and 'Writing A Compiler In Go' Books

Monkey Monkey programming language ?? project from "Writing An Interpreter In Go

Amr Hesham 1 Dec 16, 2021
Golang library for reading properties from configuration files in JSON and YAML format or from environment variables.

go-config Golang library for reading properties from configuration files in JSON and YAML format or from environment variables. Usage Create config in

null 2 Dec 6, 2021