Comments (10)
It's nice to have someone using something I wrote. I figured there'd be some problems like this showing up eventually.
Your analysis is correct. This code is trying to turn a relationship like "worksheets/sheet1.xml" into "1" and "worksheets/sheet2.xml" into "2". As you can see, it's not very flexible code. I'll try to come up with a better method soon.
from xlnt.
My latest commit, 8dc7342, should fix this problem. I've made the aforementioned code more robust (I hope). Please give it a try if you get a chance.
from xlnt.
Almost! Sorry for the delay in testing this, many thanks for the update. Unfortunately it doesn't completely fix the problem, rather it moves it into workbook.cpp
instead. Looks like there's a similar bit of code there too:
terminate called after throwing an instance of 'std::invalid_argument'
what(): stoi
...
#9 0x00007ffff7b3714b in xlnt::workbook::save (this=0x7fffffffe140, filename="book2.xlsx") at workbook.cpp:558
558 std::size_t sheet_index = std::stoi(sheet_index_string.substr(0, sheet_index_string.find('.'))) - 1;
Hopefully it's just a copy-and-paste to fix that too?
from xlnt.
Copying and pasting this code is not very elegant and means I probably did something incorrect. All the same, it seems to be working now at least to the extent that I can test it.
from xlnt.
Can you test with http://www.shikadi.net/files/book.xlsx with this change to sample1.cpp
?
diff --git a/docs/samples/sample1.cpp b/docs/samples/sample1.cpp
index 3207292..4c754e9 100644
--- a/docs/samples/sample1.cpp
+++ b/docs/samples/sample1.cpp
@@ -18,7 +18,7 @@ int main()
}
}
- xlnt::workbook workbook;
+ xlnt::workbook workbook = xlnt::reader::load_workbook("book.xlsx");
for(int i = 0; i < 3; i++)
{
from xlnt.
I tried loading it and saving it. I didn't have any problems, and the resulting copy appears identical (comparing in Google Docs since I don't have Office right now).
from xlnt.
It looks like the copy actually has two of each original worksheet and red font color is lost. I'll create issues for both of these.
from xlnt.
That's weird, I still get a segfault when it tries to save the workbook again...
from xlnt.
Did you merge in the most recent commit, 690322? Sorry it's so complicated to get started. We'll get it working soon.
from xlnt.
Oh my apologies! When you said that copying and pasting is not very elegant, I thought you weren't going to do that as a fix! I didn't realise you had already done it :-) Yes, now I update from the latest git version I no longer get a crash. Sorry about the confusion!
I do now get an error when opening the resulting file in Excel, but it looks like this is related to the formatting - dates go back to numbers etc. but I can't see any actual data loss - only the formatting. I'll let you open a new issue for that if you wish (maybe not necessary if it's a quick fix), and I'm happy to test again to confirm that's fixed too.
Thanks again for all your help! I really appreciate it.
from xlnt.
Related Issues (20)
- Loading file fails with error: attribute 'localSheetId' expected HOT 4
- Parse error!(xlnt::exception : bad cell coordinates: (#REF!))
- This is really a good library for xlsx, but the document may need improved?
- number_serialiser::deserialise returns wrong result due to buffer not being null terminated
- Unexpected attribute 'ca' when working with formular in xlsx file.
- Is it possible to write a whole record i.e std::vector<std::string> into the xlnt::worksheet instead of writing cell by cell?
- Throw "counts don`t match" exception
- How do I insert a picture as embedded in a cell ? HOT 1
- When string tables entries exceed 1000, a ',' is being inserted in the string table number, resulting in errors opening file HOT 1
- C++23 aligned storage deprecation warning
- Reference counting issues with xlnt::format_impl
- Do Excel files not support Chinese path? HOT 1
- Fresh release HOT 2
- Errors when try to use in Windows
- Crash on Release HOT 1
- Cloning project failed HOT 1
- Read xls file?
- password
- error in Add Password: wb.save("lots_of_properties.xlsx","password");
- throws exception when I use load function to load an xlsx file containing functions HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xlnt.