From 1f329e8f968014e26351a729ba7e6e3c846e96db Mon Sep 17 00:00:00 2001 From: xuri Date: Tue, 2 Feb 2021 22:23:16 +0800 Subject: 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` --- adjust.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'adjust.go') diff --git a/adjust.go b/adjust.go index f1ae536..c391cb1 100644 --- a/adjust.go +++ b/adjust.go @@ -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. // @@ -39,6 +39,7 @@ func (f *File) adjustHelper(sheet string, dir adjustDirection, num, offset int) if err != nil { return err } + sheetID := f.getSheetID(sheet) if dir == rows { f.adjustRowDimensions(ws, num, offset) } else { @@ -51,7 +52,7 @@ func (f *File) adjustHelper(sheet string, dir adjustDirection, num, offset int) if err = f.adjustAutoFilter(ws, dir, num, offset); err != nil { return err } - if err = f.adjustCalcChain(dir, num, offset); err != nil { + if err = f.adjustCalcChain(dir, num, offset, sheetID); err != nil { return err } checkSheet(ws) @@ -197,7 +198,7 @@ func (f *File) adjustAutoFilterHelper(dir adjustDirection, coordinates []int, nu // areaRefToCoordinates provides a function to convert area reference to a // pair of coordinates. func (f *File) areaRefToCoordinates(ref string) ([]int, error) { - rng := strings.Split(ref, ":") + rng := strings.Split(strings.Replace(ref, "$", "", -1), ":") return areaRangeToCoordinates(rng[0], rng[1]) } @@ -310,11 +311,14 @@ func (f *File) deleteMergeCell(ws *xlsxWorksheet, idx int) { // adjustCalcChain provides a function to update the calculation chain when // inserting or deleting rows or columns. -func (f *File) adjustCalcChain(dir adjustDirection, num, offset int) error { +func (f *File) adjustCalcChain(dir adjustDirection, num, offset, sheetID int) error { if f.CalcChain == nil { return nil } for index, c := range f.CalcChain.C { + if c.I != sheetID { + continue + } colNum, rowNum, err := CellNameToCoordinates(c.R) if err != nil { return err -- cgit v1.2.1