Code Monkey home page Code Monkey logo

Comments (13)

edithemmings avatar edithemmings commented on June 3, 2024 1

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.

zdavatz avatar zdavatz commented on June 3, 2024

Have you tried writing to a new file? Does that work?

from spreadsheet.

edithemmings avatar edithemmings commented on June 3, 2024

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.

zdavatz avatar zdavatz commented on June 3, 2024

which software created the original file you are trying to edit with the Spreadsheet Gem?

from spreadsheet.

zdavatz avatar zdavatz commented on June 3, 2024

Was the Original File created by Openoffice or MS Office? On Mac or on Windows? Any chances of seeing the original file?

from spreadsheet.

edithemmings avatar edithemmings commented on June 3, 2024

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.

zdavatz avatar zdavatz commented on June 3, 2024

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.

edithemmings avatar edithemmings commented on June 3, 2024

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.

zdavatz avatar zdavatz commented on June 3, 2024

Can we try to reproduce this with a sample file of yours?

from spreadsheet.

edithemmings avatar edithemmings commented on June 3, 2024

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.

zdavatz avatar zdavatz commented on June 3, 2024

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.

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.