Skip to content

Conversation

@Arteeck
Copy link

@Arteeck Arteeck commented Feb 27, 2024

The scenario:
I need to copy 1 named range from the template 50,000 (or even more) times into the resulting file

When setting the cell value, the IsInferiorMergedCell() method is called, which significantly slows down the speed of operation with a large number of merged ranges. Although if I manually make a merge, I know in advance whether I need to set a value in this cell or not

Initially, I thought about making a public method SetValue(XLCellValue value, bool checkMergedRanges), which will avoid this check, but the problem is that the setter FormulaA1, which is called in the SetValue() method, also contains the IsInferiorMergedCell() call.

So I decided to just add the IsInferiorMergedCellUserDefined property, which will bypass this check. I admit that the solution is not the best, but it suits me. I wanted to highlight the problem more, maybe someone has a better solution right away

Code for reproduce: https://gist.github.com/Arteeck/32de98b54ec85cc9ae923766b73e7562

Template: template.xlsx

Sampling without IsInferiorMergedCellUserDefined:
image

Sampling with IsInferiorMergedCellUserDefined:
image

@Arteeck Arteeck changed the title Optimized setting the value of a cell if the merge state of the cell is known in advance Optimize setting the value of a cell if the merge state of the cell is known in advance Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant