diff options
author | xuri <xuri.me@gmail.com> | 2021-02-02 22:23:16 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2021-02-02 22:23:16 +0800 |
commit | 1f329e8f968014e26351a729ba7e6e3c846e96db (patch) | |
tree | 16d5e3629e071eb313e914badd6ec55f369c004e /lib.go | |
parent | db7b4ee36200df4b4838c2111e81808016b4f6ef (diff) |
This closes #774, closes #775 and closes #776
- correct adjust calculation chain in duplicate rows
- correct adjust defined name in the workbook when delete worksheet
- use absolute reference in the auto filters defined name to make it compatible with OpenOffice
- API `CoordinatesToCellName` have a new optional param to specify if using an absolute reference format
- Fix cyclomatic complexity issue of internal function `newFills` and `parseToken`
Diffstat (limited to 'lib.go')
-rw-r--r-- | lib.go | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -1,4 +1,4 @@ -// Copyright 2016 - 2020 The excelize Authors. All rights reserved. Use of +// Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of // this source code is governed by a BSD-style license that can be found in // the LICENSE file. // @@ -201,13 +201,20 @@ func CellNameToCoordinates(cell string) (int, int, error) { // Example: // // excelize.CoordinatesToCellName(1, 1) // returns "A1", nil +// excelize.CoordinatesToCellName(1, 1, true) // returns "$A$1", nil // -func CoordinatesToCellName(col, row int) (string, error) { +func CoordinatesToCellName(col, row int, abs ...bool) (string, error) { if col < 1 || row < 1 { return "", fmt.Errorf("invalid cell coordinates [%d, %d]", col, row) } + sign := "" + for _, a := range abs { + if a { + sign = "$" + } + } colname, err := ColumnNumberToName(col) - return colname + strconv.Itoa(row), err + return sign + colname + sign + strconv.Itoa(row), err } // boolPtr returns a pointer to a bool with the given value. |