Comments (15)
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.
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.
Interesting, thank you for this report. Why do you want to create a file like this?
from spreadsheet.
from spreadsheet.
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.
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.
that is possible. Can you share your produtive code here?
from spreadsheet.
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.
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.
- The gem attempts to read from a file it's meant to be writing to.
- 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.
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.
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.
so spreadsheet creates the XLS file?
from spreadsheet.
Yes.
from spreadsheet.
Have you tried to write a simple function to create a new XLS file with spreadsheet, separate from your application?
from spreadsheet.
How many MB is the file that you try to write but fail?
from spreadsheet.
Related Issues (20)
- File `xls` styles not appearing if open by google doc HOT 2
- How to add a picture HOT 3
- Cells with text >= 32KB in length result in MS Excel failing to open HOT 6
- What's the plan about TODO (Percent style)? HOT 3
- Seemingly empty file after adding 'too many' rows HOT 1
- Save Images from Excel Spreadsheets HOT 1
- Editing existing excel HOT 8
- Failing to read XLS file: process doesn't terminate. HOT 6
- Complex Excel Structure -> Cells location jumbled upon saving HOT 13
- Error opening a spreadsheet created by this gem HOT 5
- No read Excel rows more then 65353 HOT 4
- Create an excel file with more than 256 columns HOT 5
- Adding styling to a sheet tab HOT 5
- Formula referencing value in different sheet is broken HOT 8
- Max rows count HOT 10
- Incorrect MIME type HOT 1
- Format missing after certain rows and columns HOT 7
- Workbook problem HOT 1
- Images & formatting lost after writing to existing file HOT 13
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 spreadsheet.