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.1
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.5.0
Choose a head ref

Commits on Aug 6, 2021

  1. This closes #979, fix the data validation deletion issue and tidy the…

    … internal function in the source code
    xuri committed Aug 6, 2021
    Copy the full SHA
    cf9fbaf View commit details

Commits on Aug 9, 2021

  1. Reduce cyclomatic complexities for the formula calculate function and…

    … update documentation for the API: `MergeCell` and `GetCellValue`
    xuri committed Aug 9, 2021
    Copy the full SHA
    c49e7aa View commit details

Commits on Aug 11, 2021

  1. This closes #986, fix set data validation drop list failed in some cases

    Update documentation for `GetCellValue` and simplify code
    xuri committed Aug 11, 2021
    Copy the full SHA
    43a057b View commit details

Commits on Aug 12, 2021

  1. Copy the full SHA
    61d0ed1 View commit details
  2. Speed up merge cells

    threeq authored Aug 12, 2021
    Copy the full SHA
    f6f14f5 View commit details

Commits on Aug 14, 2021

  1. Improve security and simplify code

    - Make variable name more semantic
    - Reduce cyclomatic complexities for the formula calculate function
    - Support specified unzip size limit on open file options, avoid zip bombs vulnerability attack
    - Typo fix for documentation and error message
    xuri committed Aug 14, 2021
    Copy the full SHA
    48c16de View commit details
  2. Copy the full SHA
    b02f864 View commit details

Commits on Aug 16, 2021

  1. This closes #989, closes #990

    New API: `SetRowStyle` support for set style for the rows
    Update documentation for the `GetRows`, `SetCellStyle` and `SetColStyle`
    xuri committed Aug 16, 2021
    Copy the full SHA
    a55f354 View commit details

Commits on Aug 19, 2021

  1. Copy the full SHA
    dca03c6 View commit details

Commits on Aug 21, 2021

  1. This closes #1002, new fn: DAY ref #65

    Co-authored-by: Stani Michiels <git@rchtct.com>
    Co-authored-by: xuri <xuri.me@gmail.com>
    3 people authored Aug 21, 2021
    Copy the full SHA
    935af2e View commit details
  2. Copy the full SHA
    f280c03 View commit details
  3. Copy the full SHA
    4d716fa View commit details
  4. This closes #1006, new fn: MONTH ref #65

    Co-authored-by: xuri <xuri.me@gmail.com>
    stanim and xuri authored Aug 21, 2021
    Copy the full SHA
    9b55f4f View commit details

Commits on Aug 22, 2021

  1. - This fix panic and incorrect cell read on some case

    - Make unit test on Go 1.7
    - API documentation updated
    xuri committed Aug 22, 2021
    Copy the full SHA
    a2d4497 View commit details
  2. Copy the full SHA
    cd030d4 View commit details

Commits on Aug 25, 2021

  1. This closes #1012, support specify the formula in the data validation…

    … range, and update the documentation for the `AddPicture`
    xuri committed Aug 25, 2021
    Copy the full SHA
    7d9b927 View commit details

Commits on Aug 28, 2021

  1. Copy the full SHA
    c3d1d7d View commit details
  2. Copy the full SHA
    5e1fbd6 View commit details

Commits on Sep 3, 2021

  1. Copy the full SHA
    2616aa8 View commit details

Commits on Sep 5, 2021

  1. This closes #998

    - Support text comparison in the formula, also ref #65
    - `GetCellValue`, `GetRows`, `GetCols`, `Rows` and `Cols` support to specify read cell with raw value, ref #621
    - Add missing properties for the cell formula
    - Update the unit test for the `CalcCellValue`
    xuri committed Sep 5, 2021
    Copy the full SHA
    32b23ef View commit details
  2. This closes #993, closes #1014

    - Fix formula percentages calculated incorrectly
    - Make UpdateLinkedValue skip macro sheet
    - Fix conditional format bottom N not working
    xuri committed Sep 5, 2021
    Copy the full SHA
    684603b View commit details

Commits on Sep 8, 2021

  1. Copy the full SHA
    72d84c0 View commit details

Commits on Sep 9, 2021

  1. 4
    Copy the full SHA
    dad8f49 View commit details

Commits on Sep 10, 2021

  1. This closes #1017, fix duplicate image caused by incorrect internal r…

    …elationships ID calculation
    xuri committed Sep 10, 2021
    Copy the full SHA
    52609ba View commit details

Commits on Sep 13, 2021

  1. Copy the full SHA
    4ef6872 View commit details

Commits on Sep 14, 2021

  1. Copy the full SHA
    1ba3690 View commit details

Commits on Sep 16, 2021

  1. - new formula functions: DATEVALUE, ref #65

    - fix ineffectual variable assignments
    - timeout in go test
    xuri committed Sep 16, 2021
    Copy the full SHA
    2add938 View commit details

Commits on Sep 19, 2021

  1. This closes #833, closes #845, and closes #1022, breaking changes

    - Close spreadsheet and row's iterator required
    - New options `WorksheetUnzipMemLimit` have been added
    - Improve streaming reading performance, memory usage decrease about 93.7%
    xuri committed Sep 19, 2021
    Copy the full SHA
    790c363 View commit details

Commits on Sep 24, 2021

  1. new formula function: DAYS, ref #65

    xuri committed Sep 24, 2021
    Copy the full SHA
    c05b9fe View commit details

Commits on Sep 25, 2021

  1. Copy the full SHA
    490f306 View commit details

Commits on Sep 28, 2021

  1. This closes #1027 and closes #1028

    * Fix build-in scientific number format failed
    * An error will be returned if given an invalid custom number format when creating a new style
    xuri committed Sep 28, 2021
    Copy the full SHA
    2d8b5b1 View commit details

Commits on Sep 29, 2021

  1. Copy the full SHA
    e52e755 View commit details

Commits on Oct 1, 2021

  1. initialize formula function TRANSPOSE, ref #65 and remove unused expo…

    …rted error variable ErrToExcelTime
    xuri committed Oct 1, 2021
    Copy the full SHA
    28841af View commit details

Commits on Oct 10, 2021

  1. Copy the full SHA
    aa8f6f0 View commit details

Commits on Oct 11, 2021

  1. Copy the full SHA
    58fd279 View commit details

Commits on Oct 15, 2021

  1. This closes #1031, fix small float parsed error in some case

    - new formula function: YEARFRAC, ref #65
    - update the codecov version
    - remove unused variable
    xuri committed Oct 15, 2021
    Copy the full SHA
    de38402 View commit details
  2. Copy the full SHA
    c64ce0f View commit details

Commits on Oct 16, 2021

  1. ref #65, new formula function: TIME

    xuri committed Oct 16, 2021
    Copy the full SHA
    cf8766d View commit details

Commits on Oct 17, 2021

  1. Copy the full SHA
    c89b64c View commit details
  2. Copy the full SHA
    620f873 View commit details

Commits on Oct 18, 2021

  1. ref #65: new formula functions IFNA and IFS and fix string compare re…

    …sult issue in arithmetic operations
    xuri committed Oct 18, 2021
    Copy the full SHA
    5f907b7 View commit details

Commits on Oct 19, 2021

  1. Copy the full SHA
    1df7f32 View commit details

Commits on Oct 20, 2021

  1. Copy the full SHA
    49e80b9 View commit details

Commits on Oct 21, 2021

  1. Copy the full SHA
    f126f63 View commit details

Commits on Oct 23, 2021

  1. Copy the full SHA
    71684d9 View commit details

Commits on Oct 24, 2021

  1. Copy the full SHA
    154effd View commit details

Commits on Oct 25, 2021

  1. Copy the full SHA
    08087e1 View commit details

Commits on Oct 27, 2021

  1. Copy the full SHA
    2e9635e View commit details

Commits on Oct 28, 2021

  1. Copy the full SHA
    ffc9989 View commit details

Commits on Oct 29, 2021

  1. Copy the full SHA
    5c4627a View commit details
Showing with 10,937 additions and 2,858 deletions.
  1. +3 −3 .github/workflows/go.yml
  2. +1 −0 .gitignore
  3. +13 −1 README.md
  4. +14 −2 README_zh.md
  5. +31 −73 adjust.go
  6. +210 −24 adjust_test.go
  7. +6,288 −1,809 calc.go
  8. +1,561 −109 calc_test.go
  9. +3 −3 calcchain.go
  10. +1 −1 calcchain_test.go
  11. +359 −62 cell.go
  12. +235 −15 cell_test.go
  13. +6 −4 chart_test.go
  14. +32 −18 col.go
  15. +35 −35 col_test.go
  16. +3 −3 comment.go
  17. +6 −4 comment_test.go
  18. +8 −6 crypt.go
  19. +9 −6 crypt_test.go
  20. +82 −14 datavalidation.go
  21. +45 −6 datavalidation_test.go
  22. +48 −2 date.go
  23. +15 −1 date_test.go
  24. +103 −3 docProps.go
  25. +51 −4 docProps_test.go
  26. +54 −3 errors.go
  27. +1 −1 errors_test.go
  28. +124 −48 excelize.go
  29. +60 −54 excelize_test.go
  30. +45 −19 file.go
  31. +19 −9 file_test.go
  32. +265 −40 lib.go
  33. +109 −10 lib_test.go
  34. +156 −73 merge.go
  35. +32 −16 merge_test.go
  36. +57 −25 picture.go
  37. +15 −12 picture_test.go
  38. +34 −30 pivotTable.go
  39. +2 −6 pivotTable_test.go
  40. +172 −45 rows.go
  41. +65 −28 rows_test.go
  42. +33 −1 shape.go
  43. +65 −3 shape_test.go
  44. +121 −60 sheet.go
  45. +48 −6 sheet_test.go
  46. +5 −5 sheetpr.go
  47. +9 −9 sparkline.go
  48. +7 −7 sparkline_test.go
  49. +25 −9 stream.go
  50. +43 −25 stream_test.go
  51. +41 −19 styles.go
  52. +60 −5 styles_test.go
  53. +1 −1 table.go
  54. +5 −5 table_test.go
  55. +12 −3 templates.go
  56. BIN test/Book1.xlsx
  57. +35 −23 xmlApp.go
  58. +5 −3 xmlChartSheet.go
  59. +32 −15 xmlDrawing.go
  60. +4 −4 xmlPivotTable.go
  61. +1 −21 xmlSharedStrings.go
  62. +13 −7 xmlWorksheet.go
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.15.x, 1.16.x]
go-version: [1.15.x, 1.16.x, 1.17.x]
os: [ubuntu-latest, macos-latest, windows-latest]
targetplatform: [x86, x64]

@@ -28,10 +28,10 @@ jobs:
run: go build -v .

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

- name: Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v2
with:
file: coverage.txt
flags: unittests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ test/Test*.xlsm
test/BadEncrypt.xlsx
test/BadWorkbook.SaveAsEmptyStruct.xlsx
test/*.png
test/excelize-*
*.out
*.test
.idea
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ Excelize is a library written in pure Go providing a set of functions that allow
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.
- If your packages are managed using [Go Modules](https://go.dev/blog/using-go-modules), please install with following command.

```bash
go get github.com/xuri/excelize/v2
@@ -77,6 +77,12 @@ func main() {
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 {
@@ -180,6 +186,12 @@ func main() {
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)
16 changes: 14 additions & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ Excelize 是 Go 语言编写的用于操作 Office Excel 文档基础库,基
go get github.com/xuri/excelize
```

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

```bash
go get github.com/xuri/excelize/v2
@@ -77,6 +77,12 @@ func main() {
fmt.Println(err)
return
}
defer func() {
// 关闭工作簿
if err := f.Close(); err != nil {
fmt.Println(err)
}
}()
// 获取工作表中指定单元格的值
cell, err := f.GetCellValue("Sheet1", "B2")
if err != nil {
@@ -180,6 +186,12 @@ func main() {
fmt.Println(err)
return
}
defer func() {
// 关闭工作簿
if err := f.Close(); err != nil {
fmt.Println(err)
}
}()
// 插入图片
if err := f.AddPicture("Sheet1", "A2", "image.png", ""); err != nil {
fmt.Println(err)
@@ -199,7 +211,7 @@ func main() {
}`); err != nil {
fmt.Println(err)
}
// 保存文件
// 保存工作簿
if err = f.Save(); err != nil {
fmt.Println(err)
}
104 changes: 31 additions & 73 deletions adjust.go
Original file line number Diff line number Diff line change
@@ -11,10 +11,6 @@

package excelize

import (
"strings"
)

type adjustDirection bool

const (
@@ -149,7 +145,7 @@ func (f *File) adjustAutoFilter(ws *xlsxWorksheet, dir adjustDirection, num, off
return nil
}

coordinates, err := f.areaRefToCoordinates(ws.AutoFilter.Ref)
coordinates, err := areaRefToCoordinates(ws.AutoFilter.Ref)
if err != nil {
return err
}
@@ -194,62 +190,6 @@ func (f *File) adjustAutoFilterHelper(dir adjustDirection, coordinates []int, nu
return coordinates
}

// areaRefToCoordinates provides a function to convert area reference to a
// 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])
}

// areaRangeToCoordinates provides a function to convert cell range to a
// pair of coordinates.
func areaRangeToCoordinates(firstCell, lastCell string) ([]int, error) {
coordinates := make([]int, 4)
var err error
coordinates[0], coordinates[1], err = CellNameToCoordinates(firstCell)
if err != nil {
return coordinates, err
}
coordinates[2], coordinates[3], err = CellNameToCoordinates(lastCell)
return coordinates, err
}

// sortCoordinates provides a function to correct the coordinate area, such
// correct C1:B3 to B1:C3.
func sortCoordinates(coordinates []int) error {
if len(coordinates) != 4 {
return ErrCoordinates
}
if coordinates[2] < coordinates[0] {
coordinates[2], coordinates[0] = coordinates[0], coordinates[2]
}
if coordinates[3] < coordinates[1] {
coordinates[3], coordinates[1] = coordinates[1], coordinates[3]
}
return nil
}

// coordinatesToAreaRef provides a function to convert a pair of coordinates
// to area reference.
func (f *File) coordinatesToAreaRef(coordinates []int) (string, error) {
if len(coordinates) != 4 {
return "", ErrCoordinates
}
firstCell, err := CoordinatesToCellName(coordinates[0], coordinates[1])
if err != nil {
return "", err
}
lastCell, err := CoordinatesToCellName(coordinates[2], coordinates[3])
if err != nil {
return "", err
}
return firstCell + ":" + lastCell, err
}

// adjustMergeCells provides a function to update merged cells when inserting
// or deleting rows or columns.
func (f *File) adjustMergeCells(ws *xlsxWorksheet, dir adjustDirection, num, offset int) error {
@@ -259,7 +199,7 @@ func (f *File) adjustMergeCells(ws *xlsxWorksheet, dir adjustDirection, num, off

for i := 0; i < len(ws.MergeCells.Cells); i++ {
areaData := ws.MergeCells.Cells[i]
coordinates, err := f.areaRefToCoordinates(areaData.Ref)
coordinates, err := areaRefToCoordinates(areaData.Ref)
if err != nil {
return err
}
@@ -268,20 +208,23 @@ func (f *File) adjustMergeCells(ws *xlsxWorksheet, dir adjustDirection, num, off
if y1 == num && y2 == num && offset < 0 {
f.deleteMergeCell(ws, i)
i--
continue
}
y1 = f.adjustMergeCellsHelper(y1, num, offset)
y2 = f.adjustMergeCellsHelper(y2, num, offset)

y1, y2 = f.adjustMergeCellsHelper(y1, y2, num, offset)
} else {
if x1 == num && x2 == num && offset < 0 {
f.deleteMergeCell(ws, i)
i--
continue
}
x1 = f.adjustMergeCellsHelper(x1, num, offset)
x2 = f.adjustMergeCellsHelper(x2, num, offset)

x1, x2 = f.adjustMergeCellsHelper(x1, x2, num, offset)
}
if x1 == x2 && y1 == y2 {
f.deleteMergeCell(ws, i)
i--
continue
}
if areaData.Ref, err = f.coordinatesToAreaRef([]int{x1, y1, x2, y2}); err != nil {
return err
@@ -293,19 +236,34 @@ func (f *File) adjustMergeCells(ws *xlsxWorksheet, dir adjustDirection, num, off
// adjustMergeCellsHelper provides a function for adjusting merge cells to
// compare and calculate cell axis by the given pivot, operation axis and
// offset.
func (f *File) adjustMergeCellsHelper(pivot, num, offset int) int {
if pivot >= num {
pivot += offset
if pivot < 1 {
return 1
func (f *File) adjustMergeCellsHelper(p1, p2, num, offset int) (int, int) {
if p2 < p1 {
p1, p2 = p2, p1
}

if offset >= 0 {
if num <= p1 {
p1 += offset
p2 += offset
} else if num <= p2 {
p2 += offset
}
return pivot
return p1, p2
}
return pivot
if num < p1 || (num == p1 && num == p2) {
p1 += offset
p2 += offset
} else if num <= p2 {
p2 += offset
}
return p1, p2
}

// deleteMergeCell provides a function to delete merged cell by given index.
func (f *File) deleteMergeCell(ws *xlsxWorksheet, idx int) {
if idx < 0 {
return
}
if len(ws.MergeCells.Cells) > idx {
ws.MergeCells.Cells = append(ws.MergeCells.Cells[:idx], ws.MergeCells.Cells[idx+1:]...)
ws.MergeCells.Count = len(ws.MergeCells.Cells)
Loading