user1948847
user1948847

Reputation: 995

Excel formulas needs to be clicked in order to get evaluated

I've wrote an python program that basically reads excel formulas in form of `=FORMULA and write it into an output excel. Here is my code:

source=open_workbook('source.xls',formatting_info=True)

wb = copy(source)
ws = wb.get_sheet(0)

funWriter = open_workbook('template.xls')
VolProfile = funWriter.sheet_by_index(0)

    for row in range(VolProfile.nrows):
-   for col in range(VolProfile.ncols):
-        cellValue = VolProfile.cell(row,col).value
-        try:
-            if cellValue[0] == "`":
-                 cellValue = cellValue[2:]
-                 ws.write(row,col,Formula(cellValue))
-            else:
-                 pass
-         except:
-               pass
wb.save('Final.xls')

the code wrties the formula successsfully, however, the excel was unable to evaluate and generate a (#VALUE!) error unless I click onto the formula bar and press enter.

I tried to save it and press f9 and they all didnt work. Any idea on how to prevent me from clicking and pressing enter for 800 times??

Thanks!

Upvotes: 0

Views: 203

Answers (1)

Peter L.
Peter L.

Reputation: 7304

I'm NOT familiar with ANY language syntax except VBA, but to read and write FORMULA in cells one should use Cell.Formula property, not value.

Perhaps for Python it does not matter, but just the first thought.

Upvotes: 1

Related Questions