Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: qax-os/excelize
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.4.0
Choose a base ref
...
head repository: qax-os/excelize
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.4.1
Choose a head ref
Loading
Showing with 1,674 additions and 747 deletions.
  1. +6 −0 .github/FUNDING.yml
  2. +38 −0 .github/workflows/go.yml
  3. +0 −25 .travis.yml
  4. +2 −2 CONTRIBUTING.md
  5. +16 −12 README.md
  6. +16 −12 README_zh.md
  7. +6 −3 adjust.go
  8. +6 −16 adjust_test.go
  9. +189 −23 calc.go
  10. +53 −18 calc_test.go
  11. +3 −1 calcchain.go
  12. +1 −1 calcchain_test.go
  13. +48 −25 cell.go
  14. +62 −13 cell_test.go
  15. +14 −10 chart.go
  16. +10 −6 chart_test.go
  17. +19 −10 col.go
  18. +15 −14 col_test.go
  19. +30 −22 comment.go
  20. +4 −3 comment_test.go
  21. +4 −7 crypt.go
  22. +22 −16 datavalidation.go
  23. +40 −6 datavalidation_test.go
  24. +10 −25 date.go
  25. +1 −1 date_test.go
  26. +4 −4 docProps_test.go
  27. +16 −11 drawing.go
  28. +5 −4 drawing_test.go
  29. +88 −1 errors.go
  30. +47 −39 excelize.go
  31. +35 −26 excelize_test.go
  32. +76 −51 file.go
  33. +33 −11 file_test.go
  34. +3 −3 go.mod
  35. +6 −5 go.sum
  36. +104 −8 lib.go
  37. +45 −2 lib_test.go
  38. +22 −8 merge_test.go
  39. +63 −33 picture.go
  40. +11 −8 picture_test.go
  41. +41 −22 pivotTable.go
  42. +14 −5 pivotTable_test.go
  43. +25 −12 rows.go
  44. +35 −23 rows_test.go
  45. +1 −1 shape.go
  46. +101 −92 sheet.go
  47. +11 −6 sheet_test.go
  48. +6 −2 sheetpr_test.go
  49. +1 −1 sparkline.go
  50. +3 −1 sparkline_test.go
  51. +115 −24 stream.go
  52. +47 −6 stream_test.go
  53. +35 −29 styles.go
  54. +11 −3 styles_test.go
  55. +5 −4 table.go
  56. +1 −0 xmlChart.go
  57. +2 −2 xmlComments.go
  58. +5 −1 xmlContentTypes.go
  59. +6 −1 xmlDrawing.go
  60. +2 −2 xmlSharedStrings.go
  61. +12 −8 xmlStyles.go
  62. +5 −1 xmlWorkbook.go
  63. +17 −16 xmlWorksheet.go
6 changes: 6 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
patreon: xuri
open_collective: excelize
ko_fi: xurime
liberapay: xuri
issuehunt: xuri
custom: https://www.paypal.com/paypalme/xuri
38 changes: 38 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on: [push, pull_request]
name: build
jobs:

test:
strategy:
matrix:
go-version: [1.15.x, 1.16.x]
os: [ubuntu-latest, macos-latest, windows-latest]
targetplatform: [x86, x64]

runs-on: ${{ matrix.os }}

steps:

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2

- name: Get dependencies
run: |
env GO111MODULE=on go vet ./...
- name: Build
run: go build -v .

- name: Test
run: env GO111MODULE=on go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic

- name: Codecov
uses: codecov/codecov-action@v1
with:
file: coverage.txt
flags: unittests
name: codecov-umbrella
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ A great way to contribute to the project is to send a detailed report when you
encounter an issue. We always appreciate a well-written, thorough bug report,
and will thank you for it!

Check that [our issue database](https://github.com/360EntSecGroup-Skylar/excelize/issues)
Check that [our issue database](https://github.com/xuri/excelize/issues)
doesn't already include that problem or suggestion before submitting an issue.
If you find a match, you can use the "subscribe" button to get notified on
updates. Do *not* leave random "+1" or "I have this too" comments, as they
@@ -55,7 +55,7 @@ This section gives the experienced contributor some tips and guidelines.

Not sure if that typo is worth a pull request? Found a bug and know how to fix
it? Do it! We will appreciate it. Any significant improvement should be
documented as [a GitHub issue](https://github.com/360EntSecGroup-Skylar/excelize/issues) before
documented as [a GitHub issue](https://github.com/xuri/excelize/issues) before
anybody starts working on it.

We are always thrilled to receive pull requests. We do our best to process them
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<p align="center"><img width="650" src="./excelize.svg" alt="Excelize logo"></p>

<p align="center">
<a href="https://travis-ci.org/360EntSecGroup-Skylar/excelize"><img src="https://travis-ci.org/360EntSecGroup-Skylar/excelize.svg?branch=master" alt="Build Status"></a>
<a href="https://codecov.io/gh/360EntSecGroup-Skylar/excelize"><img src="https://codecov.io/gh/360EntSecGroup-Skylar/excelize/branch/master/graph/badge.svg" alt="Code Coverage"></a>
<a href="https://goreportcard.com/report/github.com/360EntSecGroup-Skylar/excelize"><img src="https://goreportcard.com/badge/github.com/360EntSecGroup-Skylar/excelize" alt="Go Report Card"></a>
<a href="https://pkg.go.dev/github.com/360EntSecGroup-Skylar/excelize/v2?tab=doc"><img src="https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white" alt="go.dev"></a>
<a href="https://github.com/xuri/excelize/actions/workflows/go.yml"><img src="https://github.com/xuri/excelize/actions/workflows/go.yml/badge.svg" alt="Build Status"></a>
<a href="https://codecov.io/gh/qax-os/excelize"><img src="https://codecov.io/gh/qax-os/excelize/branch/master/graph/badge.svg" alt="Code Coverage"></a>
<a href="https://goreportcard.com/report/github.com/xuri/excelize"><img src="https://goreportcard.com/badge/github.com/xuri/excelize" alt="Go Report Card"></a>
<a href="https://pkg.go.dev/github.com/xuri/excelize/v2"><img src="https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white" alt="go.dev"></a>
<a href="https://opensource.org/licenses/BSD-3-Clause"><img src="https://img.shields.io/badge/license-bsd-orange.svg" alt="Licenses"></a>
<a href="https://www.paypal.com/paypalme/xuri"><img src="https://img.shields.io/badge/Donate-PayPal-green.svg" alt="Donate"></a>
</p>
@@ -13,20 +13,20 @@

## 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&trade; 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](https://pkg.go.dev/github.com/360EntSecGroup-Skylar/excelize/v2?tab=doc) and [docs reference](https://xuri.me/excelize/).
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&trade; 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](https://pkg.go.dev/github.com/xuri/excelize/v2) and [docs reference](https://xuri.me/excelize/).

## Basic Usage

### Installation

```bash
go get github.com/360EntSecGroup-Skylar/excelize
go get github.com/xuri/excelize
```

- If your packages are managed using [Go Modules](https://blog.golang.org/using-go-modules), please install with following command.

```bash
go get github.com/360EntSecGroup-Skylar/excelize/v2
go get github.com/xuri/excelize/v2
```

### Create spreadsheet
@@ -39,7 +39,7 @@ package main
import (
"fmt"

"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/xuri/excelize/v2"
)

func main() {
@@ -68,7 +68,7 @@ package main
import (
"fmt"

"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/xuri/excelize/v2"
)

func main() {
@@ -86,6 +86,10 @@ func main() {
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")
@@ -107,7 +111,7 @@ package main
import (
"fmt"

"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/xuri/excelize/v2"
)

func main() {
@@ -167,7 +171,7 @@ import (
_ "image/jpeg"
_ "image/png"

"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/xuri/excelize/v2"
)

func main() {
@@ -204,7 +208,7 @@ func main() {

## 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](http://www.ecma-international.org/publications/standards/Ecma-376.htm).
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](https://www.ecma-international.org/publications-and-standards/standards/ecma-376/).

## Licenses

28 changes: 16 additions & 12 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<p align="center"><img width="650" src="./excelize.svg" alt="Excelize logo"></p>

<p align="center">
<a href="https://travis-ci.org/360EntSecGroup-Skylar/excelize"><img src="https://travis-ci.org/360EntSecGroup-Skylar/excelize.svg?branch=master" alt="Build Status"></a>
<a href="https://codecov.io/gh/360EntSecGroup-Skylar/excelize"><img src="https://codecov.io/gh/360EntSecGroup-Skylar/excelize/branch/master/graph/badge.svg" alt="Code Coverage"></a>
<a href="https://goreportcard.com/report/github.com/360EntSecGroup-Skylar/excelize"><img src="https://goreportcard.com/badge/github.com/360EntSecGroup-Skylar/excelize" alt="Go Report Card"></a>
<a href="https://pkg.go.dev/github.com/360EntSecGroup-Skylar/excelize/v2?tab=doc"><img src="https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white" alt="go.dev"></a>
<a href="https://github.com/xuri/excelize/actions/workflows/go.yml"><img src="https://github.com/xuri/excelize/actions/workflows/go.yml/badge.svg" alt="Build Status"></a>
<a href="https://codecov.io/gh/qax-os/excelize"><img src="https://codecov.io/gh/qax-os/excelize/branch/master/graph/badge.svg" alt="Code Coverage"></a>
<a href="https://goreportcard.com/report/github.com/xuri/excelize"><img src="https://goreportcard.com/badge/github.com/xuri/excelize" alt="Go Report Card"></a>
<a href="https://pkg.go.dev/github.com/xuri/excelize/v2"><img src="https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white" alt="go.dev"></a>
<a href="https://opensource.org/licenses/BSD-3-Clause"><img src="https://img.shields.io/badge/license-bsd-orange.svg" alt="Licenses"></a>
<a href="https://www.paypal.com/paypalme/xuri"><img src="https://img.shields.io/badge/Donate-PayPal-green.svg" alt="Donate"></a>
</p>
@@ -13,20 +13,20 @@

## 简介

Excelize 是 Go 语言编写的用于操作 Office Excel 文档基础库,基于 ECMA-376,ISO/IEC 29500 国际标准。可以使用它来读取、写入由 Microsoft Excel&trade; 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM 等多种文档格式,高度兼容带有样式、图片(表)、透视表、切片器等复杂组件的文档,并提供流式读写 API,用于处理包含大规模数据的工作簿。可应用于各类报表平台、云计算、边缘计算等系统。使用本类库要求使用的 Go 语言为 1.15 或更高版本,完整的 API 使用文档请访问 [go.dev](https://pkg.go.dev/github.com/360EntSecGroup-Skylar/excelize/v2?tab=doc) 或查看 [参考文档](https://xuri.me/excelize/)
Excelize 是 Go 语言编写的用于操作 Office Excel 文档基础库,基于 ECMA-376,ISO/IEC 29500 国际标准。可以使用它来读取、写入由 Microsoft Excel&trade; 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式,高度兼容带有样式、图片(表)、透视表、切片器等复杂组件的文档,并提供流式读写 API,用于处理包含大规模数据的工作簿。可应用于各类报表平台、云计算、边缘计算等系统。使用本类库要求使用的 Go 语言为 1.15 或更高版本,完整的 API 使用文档请访问 [go.dev](https://pkg.go.dev/github.com/xuri/excelize/v2) 或查看 [参考文档](https://xuri.me/excelize/)

## 快速上手

### 安装

```bash
go get github.com/360EntSecGroup-Skylar/excelize
go get github.com/xuri/excelize
```

- 如果您使用 [Go Modules](https://blog.golang.org/using-go-modules) 管理软件包,请使用下面的命令来安装最新版本。

```bash
go get github.com/360EntSecGroup-Skylar/excelize/v2
go get github.com/xuri/excelize/v2
```

### 创建 Excel 文档
@@ -39,7 +39,7 @@ package main
import (
"fmt"

"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/xuri/excelize/v2"
)

func main() {
@@ -68,7 +68,7 @@ package main
import (
"fmt"

"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/xuri/excelize/v2"
)

func main() {
@@ -86,6 +86,10 @@ func main() {
fmt.Println(cell)
// 获取 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")
@@ -107,7 +111,7 @@ package main
import (
"fmt"

"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/xuri/excelize/v2"
)

func main() {
@@ -167,7 +171,7 @@ import (
_ "image/jpeg"
_ "image/png"

"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/xuri/excelize/v2"
)

func main() {
@@ -204,7 +208,7 @@ func main() {

## 社区合作

欢迎您为此项目贡献代码,提出建议或问题、修复 Bug 以及参与讨论对新功能的想法。 XML 符合标准: [part 1 of the 5th edition of the ECMA-376 Standard for Office Open XML](http://www.ecma-international.org/publications/standards/Ecma-376.htm)
欢迎您为此项目贡献代码,提出建议或问题、修复 Bug 以及参与讨论对新功能的想法。 XML 符合标准: [part 1 of the 5th edition of the ECMA-376 Standard for Office Open XML](https://www.ecma-international.org/publications-and-standards/standards/ecma-376/)

## 开源许可

9 changes: 6 additions & 3 deletions adjust.go
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
package excelize

import (
"errors"
"strings"
)

@@ -199,6 +198,10 @@ func (f *File) adjustAutoFilterHelper(dir adjustDirection, coordinates []int, nu
// pair of coordinates.
func (f *File) areaRefToCoordinates(ref string) ([]int, error) {
rng := strings.Split(strings.Replace(ref, "$", "", -1), ":")
if len(rng) < 2 {
return nil, ErrParameterInvalid
}

return areaRangeToCoordinates(rng[0], rng[1])
}

@@ -219,7 +222,7 @@ func areaRangeToCoordinates(firstCell, lastCell string) ([]int, error) {
// correct C1:B3 to B1:C3.
func sortCoordinates(coordinates []int) error {
if len(coordinates) != 4 {
return errors.New("coordinates length must be 4")
return ErrCoordinates
}
if coordinates[2] < coordinates[0] {
coordinates[2], coordinates[0] = coordinates[0], coordinates[2]
@@ -234,7 +237,7 @@ func sortCoordinates(coordinates []int) error {
// to area reference.
func (f *File) coordinatesToAreaRef(coordinates []int) (string, error) {
if len(coordinates) != 4 {
return "", errors.New("coordinates length must be 4")
return "", ErrCoordinates
}
firstCell, err := CoordinatesToCellName(coordinates[0], coordinates[1])
if err != nil {
22 changes: 6 additions & 16 deletions adjust_test.go
Original file line number Diff line number Diff line change
@@ -73,20 +73,10 @@ func TestAdjustAutoFilter(t *testing.T) {
func TestAdjustHelper(t *testing.T) {
f := NewFile()
f.NewSheet("Sheet2")
f.Sheet["xl/worksheets/sheet1.xml"] = &xlsxWorksheet{
MergeCells: &xlsxMergeCells{
Cells: []*xlsxMergeCell{
{
Ref: "A:B1",
},
},
},
}
f.Sheet["xl/worksheets/sheet2.xml"] = &xlsxWorksheet{
AutoFilter: &xlsxAutoFilter{
Ref: "A1:B",
},
}
f.Sheet.Store("xl/worksheets/sheet1.xml", &xlsxWorksheet{
MergeCells: &xlsxMergeCells{Cells: []*xlsxMergeCell{{Ref: "A:B1"}}}})
f.Sheet.Store("xl/worksheets/sheet2.xml", &xlsxWorksheet{
AutoFilter: &xlsxAutoFilter{Ref: "A1:B"}})
// testing adjustHelper with illegal cell coordinates.
assert.EqualError(t, f.adjustHelper("Sheet1", rows, 0, 0), `cannot convert cell "A" to coordinates: invalid cell name "A"`)
assert.EqualError(t, f.adjustHelper("Sheet2", rows, 0, 0), `cannot convert cell "B" to coordinates: invalid cell name "B"`)
@@ -113,7 +103,7 @@ func TestAdjustCalcChain(t *testing.T) {
func TestCoordinatesToAreaRef(t *testing.T) {
f := NewFile()
_, err := f.coordinatesToAreaRef([]int{})
assert.EqualError(t, err, "coordinates length must be 4")
assert.EqualError(t, err, ErrCoordinates.Error())
_, err = f.coordinatesToAreaRef([]int{1, -1, 1, 1})
assert.EqualError(t, err, "invalid cell coordinates [1, -1]")
_, err = f.coordinatesToAreaRef([]int{1, 1, 1, -1})
@@ -124,5 +114,5 @@ func TestCoordinatesToAreaRef(t *testing.T) {
}

func TestSortCoordinates(t *testing.T) {
assert.EqualError(t, sortCoordinates(make([]int, 3)), "coordinates length must be 4")
assert.EqualError(t, sortCoordinates(make([]int, 3)), ErrCoordinates.Error())
}
Loading