-2

I need to open a .xlsx-file (without writing to it) in python, to change some fields and get the output after the formulas in some fields were calculated; I only know the input fields, the output field and the name of the sheet.

To write some code: Here is how it would look like if I would have created the library

file = excel.open("some_file.xlsx")
sheet = file[sheet_name]
for k, v in input_fields.items():
    sheet[k] = v
file.do_calculations()
print(sheet[output_field])

Is there an easy way to do this? Wich library should I use to get the result of the formulas after providing new values for some fields?

Is there a better way than using something like pyoo, maybe something that doesn't require another application (a python library is clearly better) to be installed?

I'll just thank you in advance.

CodenameLambda
  • 1,486
  • 11
  • 23

1 Answers1

1

I now came up with a (very ugly) solution.

I am now reading the xml within the xlsx-file, and I am now using eval and some regular expressions to find out wich fields are needed; and I have defined some functions to run the calculations.

It works, but it would be great if there were a better solution.

If the resulting library is ready, and I don't forget to do this; I'll add a link to the library (that'll be hosted on Github) to this answer to my own question.

CodenameLambda
  • 1,486
  • 11
  • 23