-
Notifications
You must be signed in to change notification settings - Fork 349
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
OpenXLSX::XLDocument is not saving the same string into another workbook #283
Comments
Hi @NK01 & thank you for reporting this issue. It sounds like a bug: I see nothing wrong with re-using the XLDocument variable like you do. I will have a look to understand why the document seems to not properly "reset" on ::create, when I find some time - I am currently quite busy & I hope this isn't too urgent, since you have a workaround. My apologies if this takes a few weeks for me to address. |
Thank you for the response and yeah it is not urgent, as I have already put the workaround in the code. No worries for the delay, take your time |
Thank you for your patience - I just wanted to give you a heads-up: I will start looking into this this week, and might have questions - so if you can check for notifications to respond within a few hours that would be great. :) |
Thank you for taking up this issue, I am not that well versed in programming to actually contribute to the code however I can help you with any question you might have about the issue |
Okay, so I was able to reproduce the issue and isolate the root cause: the shared strings cache was not being deleted, so that if you re-assigned the same strings that were already cached to cells in a new document, the XLDocument would think "oh, I already have those strings" and store the indexes from the previous document, but never generate the shared strings table. If you would assign strings not yet cached, they would have been added, but with the wrong index (I didn't verify, the fix was easy enough). Patched in bf5fe8a - if you could have a look at the development-aral branch, to confirm that this fixes the issue for you as well, that would be appreciated. Thank you for flagging this, technically speaking this was a memory leak as well (memory from the cache was never released). |
The below looks similar to this issue. void XLDocument::open(const std::string& fileName)
|
I have tried the patch bf5fe8a - at the development-aral branch, and can confirm that
works without any issues |
@NK01: Thank you for testing :) I will mark this issue as closed when I merge the patch into the main branch! |
Thank you for the suggestion, but those are actually initialized with default values in the XLDocument.hpp class definition, line 359 & 360.
Clearing them as you suggest is exactly the patch that I added, but in |
Okay, this patch is merged into main - closing the issue as resolved. |
The issue example:
In the above example the second workbook does not contain any data, but if I change some data in the
std::vector<std::vector<std::string>> data
matrix then the changed data is inserted into the second matrix but not anything elseCurrently the workaround is to create a new
OpenXLSX::XLDocument doc
like this:then everything works as expected.
Is the first way not correct?
The text was updated successfully, but these errors were encountered: