-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1448 Enhances the performance of checkCellInRangeRef and merging cells. #1500
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR. Using the rect
fields of merged cell in the mergeCellsParser
function instead of add cache:
diff --git a/cell.go b/cell.go
index a23296b..20400f6 100644
--- a/cell.go
+++ b/cell.go
@@ -1388,6 +1388,10 @@ func (f *File) prepareCellStyle(ws *xlsxWorksheet, col, row, style int) int {
// given cell reference.
func (f *File) mergeCellsParser(ws *xlsxWorksheet, cell string) (string, error) {
cell = strings.ToUpper(cell)
+ col, row, err := CellNameToCoordinates(cell)
+ if err != nil {
+ return cell, err
+ }
if ws.MergeCells != nil {
for i := 0; i < len(ws.MergeCells.Cells); i++ {
if ws.MergeCells.Cells[i] == nil {
@@ -1395,12 +1399,20 @@ func (f *File) mergeCellsParser(ws *xlsxWorksheet, cell string) (string, error)
i--
continue
}
- ok, err := f.checkCellInRangeRef(cell, ws.MergeCells.Cells[i].Ref)
- if err != nil {
- return cell, err
+ if ref := ws.MergeCells.Cells[i].Ref; len(ws.MergeCells.Cells[i].rect) == 0 && ref != "" {
+ if strings.Count(ref, ":") != 1 {
+ ref += ":" + ref
+ }
+ rect, err := rangeRefToCoordinates(ref)
+ if err != nil {
+ return cell, err
+ }
+ _ = sortCoordinates(rect)
+ ws.MergeCells.Cells[i].rect = rect
}
- if ok {
+ if cellInRange([]int{col, row}, ws.MergeCells.Cells[i].rect) {
cell = strings.Split(ws.MergeCells.Cells[i].Ref, ":")[0]
+ break
}
}
}
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## master #1500 +/- ##
==========================================
- Coverage 98.69% 98.65% -0.04%
==========================================
Files 31 31
Lines 24332 24344 +12
==========================================
+ Hits 24014 24017 +3
- Misses 210 216 +6
- Partials 108 111 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Enhances the performance of checkCellInRangeRef and merging cells.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for your contribution. I have made some changes based on your branch. This patch will be released in the next version.
PR Details
Enhances the performance of checkCellInRangeRef and merging cells.
Description
Enhances the performance of checkCellInRangeRef and merging cells.
Related Issue
Slow Performance when there are lots of merge cells & calculations #1448
Motivation and Context
Slow Performance when there are lots of merge cells & calculations #1448
How Has This Been Tested
run
go test
Types of changes
Checklist