Skip to content
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

Poor image insertion performance in far rows #706

Closed
a1tus opened this issue Sep 18, 2020 · 3 comments
Closed

Poor image insertion performance in far rows #706

a1tus opened this issue Sep 18, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@a1tus
Copy link

a1tus commented Sep 18, 2020

Hello.

I've used your lib to write a simple util that takes paths to images from one column, creates a thumbnail and pastes it to another column via AddPictureFromBytes.

Everything worked fine but I've noticed that for files with thousands of rows every next insertion took exponentially longer time.
For example, files with from 0 to 1k of rows are processed nearly instantly, 5-10k takes several minutes, >10k can take up to an hour.

I've found a problem, made a fork and used it so now it takes linear time to insert images anywhere.
Please consider if it can be useful for someone else.

The fix is pretty simple (in fact I've just deleted some of unused code): a1tus@2bbe157

positionObjectPixels calculates yAbs via cycle from 0 to the current row and summing getRowHeight results.
getRowHeight by itself have an identical cycle inside (not sure why it's written like that instead of accessing SheetData.row[i] directly). So that's where we get these exponential time grow.

But the most fun fact (and also why the fix is so simple) is that xAbs/yAbs results of positionObjectPixels is not used anywhere! If you think that it's still needed then we can add bool param to skip these calculations for some particular cases.

@xuri xuri added the enhancement New feature or request label Sep 27, 2020
@xuri
Copy link
Member

xuri commented Oct 3, 2020

Hi @a1tus, thanks for your feedback, could you make a PR for this fix?

@xuri xuri closed this as completed in 520aa67 Oct 17, 2020
@xuri
Copy link
Member

xuri commented Oct 17, 2020

I have fixed it, please try to use the master branch code.

@a1tus
Copy link
Author

a1tus commented Oct 20, 2020

Sorry, I was far from my working computer for some time. Many thanks, we'll update our dependencies!

EugeneAndrosovPaser pushed a commit to ceearrashee/excelize that referenced this issue Nov 14, 2020
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
…g worksheet when rename with same names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants