GithubHelp home page GithubHelp logo

Comments (10)

tfussell avatar tfussell commented on May 16, 2024

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.

tfussell avatar tfussell commented on May 16, 2024

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.

Malvineous avatar Malvineous commented on May 16, 2024

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.

tfussell avatar tfussell commented on May 16, 2024

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.

Malvineous avatar Malvineous commented on May 16, 2024

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.

tfussell avatar tfussell commented on May 16, 2024

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.

tfussell avatar tfussell commented on May 16, 2024

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.

Malvineous avatar Malvineous commented on May 16, 2024

That's weird, I still get a segfault when it tries to save the workbook again...

from xlnt.

tfussell avatar tfussell commented on May 16, 2024

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.

Malvineous avatar Malvineous commented on May 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.