vallettea / koala

Transpose your Excel calculations into python for better performances and scaling.
GNU General Public License v3.0
147 stars 59 forks source link

save updated cell values as an excel file #238

Open NSanjay opened 5 years ago

NSanjay commented 5 years ago

Hi

Apologies if this has been answered somewhere, but I went through the docs and couldn't find anything related to saving changes I make to a spreadsheet to a new .xlsx file. I understand that only the reading part has been borrowed from openpyxl. But does koala allow me to do write changes to a new excel spreadsheet? If so, I wanted to know how

Here's the code I've tried so far:

from koala.Spreadsheet import Spreadsheet

filename = "test.xlsx"
sp = Spreadsheet(filename)

# check current values
print(sp.cell_evaluate('Sheet1!BV25'))
print(sp.cell_evaluate('Sheet1!BV65'))

#change to new value
sp.cell_set_value('Sheet1!BV25', 0.05)

#check if values have updated
print(sp.cell_evaluate('Sheet1!BV25'))
print(sp.cell_evaluate('Sheet1!BV65'))

#sp.gen_graph()

#sp.prune_graph()

#sp.dump(filename.replace(".xlsx","_modified.xlsx"))

The cell BV65 is dependent on BV25. After I change the value of BV25, I see the value of BV65 has updated, but I want to save these changes as a .xlsx file, without involving Microsoft Excel during the update process.

I tried the last 3 commented lines, but MS Excel could not open the generated file.

Thanks in advance, Sanjay

SlavaKozlov commented 4 years ago

I was looking for the same thing: save to an Excel file. I don't see this as supported in the code (v 0.0.36).

The generated gzip file from a dump has nothing to do with an Excel format. It is just the cell graph.

I agree it would be super useful to be able to save the changed graph back into Excel. Without this feature, it is almost impossible to troubleshoot issues in the original Excel code (treating the Excel file as a function). It wouldn't need to be too exciting - the formatting is stripped - but it would be a valuable feature.

Thanks

charlesdwright commented 2 years ago

Yeah, me too.