Giter VIP home page Giter VIP logo

Comments (15)

jhwinters avatar jhwinters commented on June 16, 2024 1

Sorry, no - it's 43,000 lines of Ruby code. Generating the spreadsheet involves hundreds of d/b queries. I will however try to produce a standalone but complete script which demonstrates the problem.

from spreadsheet.

jhwinters avatar jhwinters commented on June 16, 2024 1

Yes. For a trivial spreadsheet that seems to work. I'm currently trying to produce a minimal standalone program which demonstrates the problem, however I've been called off to fix a production problem so that's on hold for the moment.

from spreadsheet.

zdavatz avatar zdavatz commented on June 16, 2024

Interesting, thank you for this report. Why do you want to create a file like this?

from spreadsheet.

jhwinters avatar jhwinters commented on June 16, 2024

from spreadsheet.

jhwinters avatar jhwinters commented on June 16, 2024

Perhaps I should also mention that the output files produced by the first two methods are bit-for-bit identical. The third file is exactly 1024 bytes larger.

from spreadsheet.

jhwinters avatar jhwinters commented on June 16, 2024

Further information point. The code above is not my original code, it is a reduced version which I produced to see how small a piece of code could demonstrate the problem. The spreadsheet which it is trying to save is a trivial one.

I did a bit more experimenting this morning with my real data and all three of the approaches shown above. The first and second both work and produce identical output files. The third one doesn't complete when faced with real data and produces the following exception:

Traceback (most recent call last):
	13: from lib/utils/timetabletoxls.rb:117:in `<main>'
	12: from lib/utils/timetabletoxls.rb:117:in `open'
	11: from lib/utils/timetabletoxls.rb:118:in `block in <main>'
	10: from /home/john/.rvm/gems/ruby-2.6.6@scheduler/gems/spreadsheet-1.2.6/lib/spreadsheet/workbook.rb:129:in `write'
	 9: from /home/john/.rvm/gems/ruby-2.6.6@scheduler/gems/spreadsheet-1.2.6/lib/spreadsheet/writer.rb:12:in `write'
	 8: from /home/john/.rvm/gems/ruby-2.6.6@scheduler/gems/spreadsheet-1.2.6/lib/spreadsheet/excel/writer/workbook.rb:647:in `write_workbook'
	 7: from /home/john/.rvm/gems/ruby-2.6.6@scheduler/gems/spreadsheet-1.2.6/lib/spreadsheet/excel/writer/workbook.rb:457:in `write_from_scratch'
	 6: from /home/john/.rvm/gems/ruby-2.6.6@scheduler/gems/ruby-ole-1.2.12.2/lib/ole/storage/base.rb:85:in `open'
	 5: from /home/john/.rvm/gems/ruby-2.6.6@scheduler/gems/ruby-ole-1.2.12.2/lib/ole/storage/base.rb:85:in `new'
	 4: from /home/john/.rvm/gems/ruby-2.6.6@scheduler/gems/ruby-ole-1.2.12.2/lib/ole/storage/base.rb:79:in `initialize'
	 3: from /home/john/.rvm/gems/ruby-2.6.6@scheduler/gems/ruby-ole-1.2.12.2/lib/ole/storage/base.rb:112:in `load'
	 2: from /home/john/.rvm/gems/ruby-2.6.6@scheduler/gems/ruby-ole-1.2.12.2/lib/ole/storage/base.rb:112:in `new'
	 1: from /home/john/.rvm/gems/ruby-2.6.6@scheduler/gems/ruby-ole-1.2.12.2/lib/ole/storage/base.rb:370:in `initialize'
/home/john/.rvm/gems/ruby-2.6.6@scheduler/gems/ruby-ole-1.2.12.2/lib/ole/storage/base.rb:378:in `validate!': OLE2 signature is invalid (Ole::Storage::FormatError)

It would seem that the processing the library does when passed an open file is different from what it does for a file name or StringIO object.

from spreadsheet.

zdavatz avatar zdavatz commented on June 16, 2024

that is possible. Can you share your produtive code here?

from spreadsheet.

zdavatz avatar zdavatz commented on June 16, 2024

Ok great. I think it is a problem in your script. So it is good if you create a standalone example that replicates your problem. Looking forward to seeing it.

from spreadsheet.

jhwinters avatar jhwinters commented on June 16, 2024

It's difficult to see how it could be a problem in my script (although I rule nothing out). The lines I quoted above were lifted straight out of the body of the script. If I had somehow corrupted the spreadsheet's internal data structures then one would expect all the writes to fail, rather than two succeeding and one failing.

Specific observations.

  1. The gem attempts to read from a file it's meant to be writing to.
  2. Given a less trivial spreadsheet, the gem manages to write it out via method 1, but then triggers an exception in the OLE code when invoked by method 3.

If my code had corrupted the gem's data structures then surely it should produce the same result for both methods?

The only thing I can think is that I am using it within a Rails application, so perhaps there is an interference between the Gem and something which Rails has done to file handling.

I'll try for that standalone script.

from spreadsheet.

zdavatz avatar zdavatz commented on June 16, 2024

Are you adding information to an existing file or are you creating a new file with your spreadsheet script? Yes, and if you are using Rails, you should try to separate the spreadsheet logic from the Rails logic.

from spreadsheet.

jhwinters avatar jhwinters commented on June 16, 2024

I'm creating a new file.

I'm not sure what you mean by "separate the spreadsheet logic from the Rails logic". The script reads a lot of records from the Rails database and puts selected information into cells of the newly created spreadsheet. All that works fine, but the problem comes when trying to write the spreadsheet out to a file.

from spreadsheet.

zdavatz avatar zdavatz commented on June 16, 2024

so spreadsheet creates the XLS file?

from spreadsheet.

jhwinters avatar jhwinters commented on June 16, 2024

Yes.

from spreadsheet.

zdavatz avatar zdavatz commented on June 16, 2024

Have you tried to write a simple function to create a new XLS file with spreadsheet, separate from your application?

from spreadsheet.

zdavatz avatar zdavatz commented on June 16, 2024

How many MB is the file that you try to write but fail?

from spreadsheet.

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.