Google Go (golang) library for reading and writing XLSX files. You should probably also checkout: https://github.com/360EntSecGroup-Skylar/excelize
Go
Clone or download
ryho Merge pull request #367 from treasure33/master
The length of "sheetName" is incorrectly determined utf-8 char
Latest commit f36fa3b Apr 19, 2018
Permalink
Failed to load latest commit information.
testdocs fix the wrong number of count rest empty rows Jan 10, 2018
.gitignore Make file.ToSlice() output an empty string when the cell value is an … Dec 7, 2016
.travis.yml Prevent creation of null rows when opening files with trailing empty … Dec 6, 2017
AUTHORS.txt Added an AUTHORS.txt file. Apr 1, 2016
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Aug 22, 2017
LICENSE Insert the license in the code base. Aug 22, 2017
README.org docs: fix cell.String only return a value Nov 27, 2017
cell.go More improvements to cell formatting Oct 24, 2017
cell_test.go More improvements to cell formatting Oct 24, 2017
col.go More improvements to cell formatting Oct 24, 2017
col_test.go Add hidden cell property and rudimentary column support Oct 10, 2014
common_test.go go fmt Jul 21, 2014
compatibility_test.go Make String() return just string, and use FormattedValue when an erro… Jul 14, 2017
date.go fix fraction of day calculation, round nearest to 1us Aug 11, 2016
date_test.go fix up date relate tests Aug 11, 2016
doc.go Make a minor update to the docs Oct 31, 2014
example_read_test.go Remove else branch in example_read_test when code panic Mar 2, 2018
file.go The length of "sheetName" is incorrectly determined if there are utf-… Feb 22, 2018
file_test.go Merge pull request #343 from ryho/master Oct 30, 2017
format_code.go More improvements to cell formatting Oct 24, 2017
format_code_test.go Improve Cell Fromatting Oct 17, 2017
fuzzy_test.go gofmt -s -w . Mar 9, 2016
hsl.go Initial support for themes Mar 15, 2015
lib.go Fix out of bounds Feb 13, 2018
lib_test.go Fix out of bounds Feb 13, 2018
read.go Use FormattedValue instead of String Jul 14, 2017
read_test.go Fix cases where we expect String to return an error Jul 14, 2017
reftable.go Split sharedstrings.go and renamed to reftable.go and xmlSharedString… Nov 1, 2014
reftable_test.go Don't indent marshalled XML. Dec 10, 2014
row.go Add function "SetHeight". Apr 7, 2017
row_test.go Make AddSheet return error when trying to use a duplicate name. Fixes #… Oct 10, 2015
sheet.go More improvements to cell formatting Oct 24, 2017
sheet_test.go Improve Cell Fromatting Oct 17, 2017
stream_file.go Add Stream writing Sep 12, 2017
stream_file_builder.go Add Stream writing Sep 12, 2017
stream_test.go Improve Cell Fromatting Oct 17, 2017
style.go stylistic changes May 17, 2016
style_test.go Omit unneeded cellStyles, cellStyle, cellStyle.Xf. Mar 16, 2016
templates.go Merge output-styles branch. Dec 2, 2014
theme.go gofmt Apr 18, 2015
theme_test.go Initial support for themes Mar 15, 2015
write.go 1. make WriteSlice and WriteStruct write value with builtin format to… Aug 12, 2016
write_test.go Make String() return just string, and use FormattedValue when an erro… Jul 14, 2017
xmlContentTypes.go add theme1.xml ref to ContentTypes Feb 3, 2015
xmlContentTypes_test.go add theme1.xml ref to ContentTypes Feb 3, 2015
xmlSharedStrings.go Split sharedstrings.go and renamed to reftable.go and xmlSharedString… Nov 1, 2014
xmlSharedStrings_test.go Split sharedstrings.go and renamed to reftable.go and xmlSharedString… Nov 1, 2014
xmlStyle.go Update style Nov 29, 2017
xmlStyle_test.go Omit unneeded cellStyles, cellStyle, cellStyle.Xf. Mar 16, 2016
xmlTheme.go Initial support for themes Mar 15, 2015
xmlWorkbook.go Allow partial reads Sep 15, 2017
xmlWorkbook_test.go added DefinedNames to the file struct by looping over defined names i… Nov 29, 2015
xmlWorksheet.go Merge pull request #281 from jfyne/master May 31, 2017
xmlWorksheet_test.go Added basic support for filters. Feb 15, 2017

README.org

XLSX

https://img.shields.io/travis/tealeg/xlsx/master.svg?style=flat-square https://codecov.io/gh/tealeg/xlsx/branch/master/graph/badge.svg https://godoc.org/github.com/tealeg/xlsx?status.svg https://img.shields.io/badge/license-bsd-orange.svg

Introduction

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

The support for writing XLSX files is currently extremely minimal. It will expand slowly, but in the meantime patches are welcome!

Full API docs

The full API docs can be viewed using go’s built in documentation tool, or online at godoc.org.

Basic Usage

Reading XLSX files

Here is a minimal example usage that will dump all cell data in a given XLSX file. A more complete example of this kind of functionality is contained in the XLSX2CSV program:

package main

import (
    "fmt"
    "github.com/tealeg/xlsx"
)

func main() {
    excelFileName := "/home/tealeg/foo.xlsx"
    xlFile, err := xlsx.OpenFile(excelFileName)
    if err != nil {
        ...
    }
    for _, sheet := range xlFile.Sheets {
        for _, row := range sheet.Rows {
            for _, cell := range row.Cells {
                text := cell.String()
                fmt.Printf("%s\n", text)
            }
        }
    }
}

Some additional information is available from the cell (for example, style information). For more details see the godoc output for this package.

Writing XLSX files

The following constitutes the bare minimum required to write an XLSX document.

package main

import (
    "fmt"
    "github.com/tealeg/xlsx"
)

func main() {
    var file *xlsx.File
    var sheet *xlsx.Sheet
    var row *xlsx.Row
    var cell *xlsx.Cell
    var err error

    file = xlsx.NewFile()
    sheet, err = file.AddSheet("Sheet1")
    if err != nil {
        fmt.Printf(err.Error())
    }
    row = sheet.AddRow()
    cell = row.AddCell()
    cell.Value = "I am a cell!"
    err = file.Save("MyXLSXFile.xlsx")
    if err != nil {
        fmt.Printf(err.Error())
    }
}

Contributing

We’re extremely happy to review pull requests. Please be patient, maintaining XLSX doesn’t pay anyone’s salary (to my knowledge).

If you’d like to propose a change please ensure the following:

Eat a peach - Geoff