zdavatz / spreadsheet

The Ruby Spreadsheet by ywesee GmbH
http://spreadsheet.ch
GNU General Public License v3.0
1.13k stars 240 forks source link

Editing existing excel #256

Open facuhump2409 opened 3 years ago

facuhump2409 commented 3 years ago

Hi, I've been having trouble trying to modify an excel file. What I want to do is after processing the data from the excel, change the value from the row. Here's my code: book = Spreadsheet.open "26-12 orders.xls" messages = book.worksheet "Whatsapp Messages" messages.each do |message| #All the logic message[0] = "Already processed row"

But when I open again the excel file, no modifications have been made (the "Already processed row" isn't in the file). How can a modify a row from an existing file and save it in the original excel? Is there a way to do it?

zdavatz commented 3 years ago

how was the Excel file created? Which software created the original XLS file that you are trying to edit?

facuhump2409 commented 3 years ago

It was created in Microsoft excel and then I had to change the extension from .xlsx to .xls in free office

zdavatz commented 3 years ago

So the original file was XLSX? XLSX is XML, where XLS is a binary format. We only support XLS. You should also try the LibreOffice commandline tools.

facuhump2409 commented 3 years ago

Yes, that’s why I changed its format to .xls but still I don’t see any changes in the file when trying to update a row. Is there something I’m doing wrong?

facuhump2409 commented 3 years ago

Yes, but I’m not trying to add a row but to update a row

zdavatz commented 3 years ago

are you using the file that you saved with LibreOffice to update the row via Ruby Spreadsheet Gem?

facuhump2409 commented 3 years ago

Yes

zdavatz commented 3 years ago

ok, the make a simple test script to see if that works.