Comments (13)
which software created the original file you are trying to edit with the Spreadsheet Gem?
The original template file was made manually by a human. The file that I am parsing in Spreadsheet and writing to is a Tempfile that I wrote the original file into (variable tmp
in the above example).
from spreadsheet.
It’s looking like this gem may not be the right fit for my case. I wish I had a deeper understanding (and more time) so I could contribute to researching, but realistically at this point I just need a workaround. If I can get my client on board with converting template files to xlsx, then I can use the RubyXL gem with the same logic, and the file remains intact.
Thanks so much for your time and effort! I’m happy to keep discussing/providing context if its of any further value.
from spreadsheet.
Have you tried writing to a new file? Does that work?
from spreadsheet.
Have you tried writing to a new file? Does that work?
@zdavatz Could you be more specific? It looks like you're suggesting writing my data to a new file instead of the tmp copy of the template, which would defeat the purpose of what I am trying to do. It is the existing images and styling in the template that are getting lost when I write to unrelated cells/sheets.
from spreadsheet.
which software created the original file you are trying to edit with the Spreadsheet Gem?
from spreadsheet.
Was the Original File created by Openoffice or MS Office? On Mac or on Windows? Any chances of seeing the original file?
from spreadsheet.
Was the Original File created by Openoffice or MS Office? On Mac or on Windows? Any chances of seeing the original file?
I'm not able to share the original file unfortunately. And I do not know the circumstances of its original creation. My client has many template files like this that have existed for a long time. If there are ways they could re-create the templates for a better chance of success, then I am all ears.
from spreadsheet.
I would try to created the templates with Ruby spreadsheet from the start, then modify the file and then save as a new file. Sometimes the software creating the original files adds binary information, that Ruby Spreadsheet does not add, then all fails. So if you can, I would go the whole way with Ruby Spreadsheet.
from spreadsheet.
I would try to created the templates with Ruby spreadsheet from the start, then modify the file and then save as a new file. Sometimes the software creating the original files adds binary information, that Ruby Spreadsheet does not add, then all fails. So if you can, I would go the whole way with Ruby Spreadsheet.
Ok that could explain it, but I'm still not understanding why this works perfectly:
book = Spreadsheet.open(tmp)
io = StringIO.new
book.write(io)
io.rewind
But this destroys the binary info:
book = Spreadsheet.open(tmp)
sheet = book.worksheet(0)
sheet.rows[1][0] = 'hello'
io = StringIO.new
book.write(io)
io.rewind
What am I missing?
from spreadsheet.
Can we try to reproduce this with a sample file of yours?
from spreadsheet.
Can we try to reproduce this with a sample file of yours?
I was able to reproduce with this template file:
template.xls
And here is the resulting export file with "hello" written to it. The image on the second sheet has been lost.
export.xls
from spreadsheet.
Ok, so the original file was created by Miguel Rocafort. Which software did he use to create the file? Which OS? Did he use the spreadsheet gem to the create the file template.xls?
from spreadsheet.
Ok, so the original file was created by Miguel Rocafort. Which software did he use to create the file? Which OS? Did he use the spreadsheet gem to the create the file template.xls?
Not sure who that is, but the spreadsheet gem was not used to create the template file. These templates are created by users -- not with this gem, so using the gem to produce test templates does not match my use case. I used this chrome extension to create the above test file: https://chromewebstore.google.com/detail/xls-editor/iobjaooppmgjlgomfpaohhncpfjpigaf
From what I understood you were looking to see the behavior reproduced, and the above test file matches what I'm seeing with my users' files.
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
- Cannot write spreadsheet to an already opened file HOT 15
- 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
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.