Skip to content

Commit c83efc6

Browse files
Merge branch 'master' of https://github.com/qax-os/excelize into qax-os-master
2 parents eaee8d4 + 55e152f commit c83efc6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+6534
-5185
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Bug report
2+
description: Create a report to help us improve
3+
body:
4+
- type: markdown
5+
attributes:
6+
value: |
7+
If you are reporting a new issue, make sure that we do not have any duplicates already open. You can ensure this by searching the issue list for this repository. If there is a duplicate, please close your issue and add a comment to the existing issue instead.
8+
9+
- type: textarea
10+
id: description
11+
attributes:
12+
label: Description
13+
description: Briefly describe the problem you are having in a few paragraphs.
14+
validations:
15+
required: true
16+
17+
- type: textarea
18+
id: reproduction-steps
19+
attributes:
20+
label: Steps to reproduce the issue
21+
description: Explain how to cause the issue in the provided reproduction.
22+
placeholder: |
23+
1.
24+
2.
25+
3.
26+
validations:
27+
required: true
28+
29+
- type: textarea
30+
id: received
31+
attributes:
32+
label: Describe the results you received
33+
validations:
34+
required: true
35+
36+
- type: textarea
37+
id: expected
38+
attributes:
39+
label: Describe the results you expected
40+
validations:
41+
required: true
42+
43+
- type: input
44+
id: go-version
45+
attributes:
46+
label: Go version
47+
description: |
48+
Output of `go version`:
49+
placeholder: e.g. 1.23.4
50+
validations:
51+
required: true
52+
53+
- type: input
54+
id: excelize-version
55+
attributes:
56+
label: Excelize version or commit ID
57+
description: |
58+
Which version of Excelize are you using?
59+
placeholder: e.g. 2.9.0
60+
validations:
61+
required: true
62+
63+
- type: textarea
64+
id: env
65+
attributes:
66+
label: Environment
67+
description: Environment details (OS, Microsoft Excel™ version, physical, etc.)
68+
render: shell
69+
validations:
70+
required: true
71+
72+
- type: checkboxes
73+
id: checkboxes
74+
attributes:
75+
label: Validations
76+
description: Before submitting the issue, please make sure you do the following
77+
options:
78+
- label: Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
79+
required: true
80+
- label: The provided reproduction is a minimal reproducible example of the bug.
81+
required: true

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
blank_issues_enabled: false

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Feature request
2+
description: Suggest an idea for this project
3+
body:
4+
- type: markdown
5+
attributes:
6+
value: |
7+
If you are reporting a new issue, make sure that we do not have any duplicates already open. You can ensure this by searching the issue list for this repository. If there is a duplicate, please close your issue and add a comment to the existing issue instead.
8+
9+
- type: textarea
10+
id: description
11+
attributes:
12+
label: Description
13+
description: Describe the feature that you would like added
14+
validations:
15+
required: true
16+
17+
- type: textarea
18+
id: additional-context
19+
attributes:
20+
label: Additional context
21+
description: Any other context or screenshots about the feature request here?
22+
23+
- type: checkboxes
24+
id: checkboxes
25+
attributes:
26+
label: Validations
27+
description: Before submitting the issue, please make sure you do the following
28+
options:
29+
- label: Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.
30+
required: true

.github/workflows/go.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
test:
66
strategy:
77
matrix:
8-
go-version: [1.20.x, '>=1.21.1', 1.22.x, 1.23.x]
8+
go-version: [1.23.x, 1.24.x]
99
os: [ubuntu-24.04, macos-13, windows-latest]
1010
targetplatform: [x86, x64]
1111

@@ -28,8 +28,17 @@ jobs:
2828
- name: Build
2929
run: go build -v .
3030

31+
- name: Build on ARM
32+
if: runner.os == 'Linux'
33+
run: |
34+
GOARCH=arm GOARM=5 go build .
35+
GOARCH=arm GOARM=6 go build .
36+
GOARCH=arm GOARM=7 go build .
37+
GOARCH=arm64 go build .
38+
GOARCH=arm64 GOOS=android go build .
39+
3140
- name: Test
32-
run: env GO111MODULE=on go test -v -timeout 30m -race ./... -coverprofile='coverage.txt' -covermode=atomic
41+
run: env GO111MODULE=on go test -v -timeout 50m -race ./... -coverprofile='coverage.txt' -covermode=atomic
3342

3443
- name: Codecov
3544
uses: codecov/codecov-action@v5

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
## Introduction
1515

16-
Excelize is a library written in pure Go providing a set of functions that allow you to write to and read from XLAM / XLSM / XLSX / 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.20 or later. There are some [incompatible changes](https://github.com/golang/go/issues/61881) in the Go 1.21.0, the Excelize library can not working with that version normally, if you are using the Go 1.21.x, please upgrade to the Go 1.21.1 and later version. The full 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/).
16+
Excelize is a library written in pure Go providing a set of functions that allow you to write to and read from XLAM / XLSM / XLSX / 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.23.0 or later. The full 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/).
1717

1818
## Basic Usage
1919

README_zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
## 简介
1515

16-
Excelize 是 Go 语言编写的用于操作 Office Excel 文档基础库,基于 ECMA-376,ISO/IEC 29500 国际标准。可以使用它来读取、写入由 Microsoft Excel™ 2007 及以上版本创建的电子表格文档。支持 XLAM / XLSM / XLSX / XLTM / XLTX 等多种文档格式,高度兼容带有样式、图片(表)、透视表、切片器等复杂组件的文档,并提供流式读写函数,用于处理包含大规模数据的工作簿。可应用于各类报表平台、云计算、边缘计算等系统。使用本类库要求使用的 Go 语言为 1.20 或更高版本,请注意,Go 1.21.0 中存在[不兼容的更改](https://github.com/golang/go/issues/61881),导致 Excelize 基础库无法在该版本上正常工作,如果您使用的是 Go 1.21.x,请升级到 Go 1.21.1 及更高版本。完整的使用文档请访问 [go.dev](https://pkg.go.dev/github.com/xuri/excelize/v2) 或查看 [参考文档](https://xuri.me/excelize/)
16+
Excelize 是 Go 语言编写的用于操作 Office Excel 文档基础库,基于 ECMA-376,ISO/IEC 29500 国际标准。可以使用它来读取、写入由 Microsoft Excel™ 2007 及以上版本创建的电子表格文档。支持 XLAM / XLSM / XLSX / XLTM / XLTX 等多种文档格式,高度兼容带有样式、图片(表)、透视表、切片器等复杂组件的文档,并提供流式读写函数,用于处理包含大规模数据的工作簿。可应用于各类报表平台、云计算、边缘计算等系统。使用本类库要求使用的 Go 语言为 1.23.0 或更高版本。完整的使用文档请访问 [go.dev](https://pkg.go.dev/github.com/xuri/excelize/v2) 或查看 [参考文档](https://xuri.me/excelize/)
1717

1818
## 快速上手
1919

adjust.go

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// writing spreadsheet documents generated by Microsoft Excel™ 2007 and later.
88
// Supports complex components by high compatibility, and provided streaming
99
// API for generating or reading data from a worksheet with huge amounts of
10-
// data. This library needs Go version 1.20 or later.
10+
// data. This library needs Go version 1.23 or later.
1111

1212
package excelize
1313

@@ -38,10 +38,10 @@ var adjustHelperFunc = [9]func(*File, *xlsxWorksheet, string, adjustDirection, i
3838
return f.adjustDataValidations(ws, sheet, dir, num, offset, sheetID)
3939
},
4040
func(f *File, ws *xlsxWorksheet, sheet string, dir adjustDirection, num, offset, sheetID int) error {
41-
return f.adjustDefinedNames(ws, sheet, dir, num, offset, sheetID)
41+
return f.adjustDefinedNames(sheet, dir, num, offset)
4242
},
4343
func(f *File, ws *xlsxWorksheet, sheet string, dir adjustDirection, num, offset, sheetID int) error {
44-
return f.adjustDrawings(ws, sheet, dir, num, offset, sheetID)
44+
return f.adjustDrawings(ws, sheet, dir, num, offset)
4545
},
4646
func(f *File, ws *xlsxWorksheet, sheet string, dir adjustDirection, num, offset, sheetID int) error {
4747
return f.adjustMergeCells(ws, sheet, dir, num, offset, sheetID)
@@ -475,20 +475,15 @@ func transformParenthesesToken(token efp.Token) string {
475475
// adjustRangeSheetName returns replaced range reference by given source and
476476
// target sheet name.
477477
func adjustRangeSheetName(rng, source, target string) string {
478+
source = escapeSheetName(source)
478479
cellRefs := strings.Split(rng, ",")
479480
for i, cellRef := range cellRefs {
480481
rangeRefs := strings.Split(cellRef, ":")
481482
for j, rangeRef := range rangeRefs {
482483
parts := strings.Split(rangeRef, "!")
483484
for k, part := range parts {
484-
singleQuote := strings.HasPrefix(part, "'") && strings.HasSuffix(part, "'")
485-
if singleQuote {
486-
part = strings.TrimPrefix(strings.TrimSuffix(part, "'"), "'")
487-
}
488-
if part == source {
489-
if part = target; singleQuote {
490-
part = "'" + part + "'"
491-
}
485+
if strings.TrimPrefix(strings.TrimSuffix(part, "'"), "'") == source {
486+
part = escapeSheetName(target)
492487
}
493488
parts[k] = part
494489
}
@@ -847,7 +842,7 @@ func (f *File) adjustCalcChain(ws *xlsxWorksheet, sheet string, dir adjustDirect
847842
// If sheet ID is omitted, it is assumed to be the same as the i value of
848843
// the previous cell.
849844
var prevSheetID int
850-
for i := 0; i < len(f.CalcChain.C); i++ {
845+
for i := 0; f.CalcChain != nil && i < len(f.CalcChain.C); i++ {
851846
c := f.CalcChain.C[i]
852847
if c.I == 0 {
853848
c.I = prevSheetID
@@ -969,7 +964,7 @@ func (f *File) adjustDataValidations(ws *xlsxWorksheet, sheet string, dir adjust
969964
return err
970965
}
971966
if worksheet.DataValidations == nil {
972-
return nil
967+
continue
973968
}
974969
for i := 0; i < len(worksheet.DataValidations.DataValidation); i++ {
975970
dv := worksheet.DataValidations.DataValidation[i]
@@ -1034,7 +1029,7 @@ func (from *xlsxFrom) adjustDrawings(dir adjustDirection, num, offset int, editA
10341029

10351030
// adjustDrawings updates the ending anchor of the two cell anchor pictures
10361031
// and charts object when inserting or deleting rows or columns.
1037-
func (to *xlsxTo) adjustDrawings(dir adjustDirection, num, offset int, editAs string, ok bool) error {
1032+
func (to *xlsxTo) adjustDrawings(dir adjustDirection, num, offset int, ok bool) error {
10381033
if dir == columns && to.Col+1 >= num && to.Col+offset >= 0 && ok {
10391034
if to.Col+offset >= MaxColumns {
10401035
return ErrColumnNumber
@@ -1054,32 +1049,38 @@ func (to *xlsxTo) adjustDrawings(dir adjustDirection, num, offset int, editAs st
10541049
// inserting or deleting rows or columns.
10551050
func (a *xdrCellAnchor) adjustDrawings(dir adjustDirection, num, offset int) error {
10561051
editAs := a.EditAs
1057-
if a.From == nil || a.To == nil || editAs == "absolute" {
1052+
if (a.From == nil && (a.To == nil || a.Ext == nil)) || editAs == "absolute" {
10581053
return nil
10591054
}
10601055
ok, err := a.From.adjustDrawings(dir, num, offset, editAs)
10611056
if err != nil {
10621057
return err
10631058
}
1064-
return a.To.adjustDrawings(dir, num, offset, editAs, ok || editAs == "")
1059+
if a.To != nil {
1060+
return a.To.adjustDrawings(dir, num, offset, ok || editAs == "")
1061+
}
1062+
return err
10651063
}
10661064

10671065
// adjustDrawings updates the existing two cell anchor pictures and charts
10681066
// object when inserting or deleting rows or columns.
10691067
func (a *xlsxCellAnchorPos) adjustDrawings(dir adjustDirection, num, offset int, editAs string) error {
1070-
if a.From == nil || a.To == nil || editAs == "absolute" {
1068+
if (a.From == nil && (a.To == nil || a.Ext == nil)) || editAs == "absolute" {
10711069
return nil
10721070
}
10731071
ok, err := a.From.adjustDrawings(dir, num, offset, editAs)
10741072
if err != nil {
10751073
return err
10761074
}
1077-
return a.To.adjustDrawings(dir, num, offset, editAs, ok || editAs == "")
1075+
if a.To != nil {
1076+
return a.To.adjustDrawings(dir, num, offset, ok || editAs == "")
1077+
}
1078+
return err
10781079
}
10791080

10801081
// adjustDrawings updates the pictures and charts object when inserting or
10811082
// deleting rows or columns.
1082-
func (f *File) adjustDrawings(ws *xlsxWorksheet, sheet string, dir adjustDirection, num, offset, sheetID int) error {
1083+
func (f *File) adjustDrawings(ws *xlsxWorksheet, sheet string, dir adjustDirection, num, offset int) error {
10831084
if ws.Drawing == nil {
10841085
return nil
10851086
}
@@ -1128,12 +1129,17 @@ func (f *File) adjustDrawings(ws *xlsxWorksheet, sheet string, dir adjustDirecti
11281129
return err
11291130
}
11301131
}
1132+
for _, anchor := range wsDr.OneCellAnchor {
1133+
if err = anchorCb(anchor); err != nil {
1134+
return err
1135+
}
1136+
}
11311137
return nil
11321138
}
11331139

11341140
// adjustDefinedNames updates the cell reference of the defined names when
11351141
// inserting or deleting rows or columns.
1136-
func (f *File) adjustDefinedNames(ws *xlsxWorksheet, sheet string, dir adjustDirection, num, offset, sheetID int) error {
1142+
func (f *File) adjustDefinedNames(sheet string, dir adjustDirection, num, offset int) error {
11371143
wb, err := f.workbookReader()
11381144
if err != nil {
11391145
return err

0 commit comments

Comments
 (0)