Here are the things I am trying to do
- Read Excel file with formulas into pandas dataframe
- Change values in some cell
- Evaluate the cell values according to the formulas
- Finally, save that file as html
Here's my code
import pandas as pd
import numpy as np
from openpyxl import load_workbook
wb = load_workbook(filename = 'initial.xlsx')
sheet_names = wb.get_sheet_names()
name = sheet_names[0]
sheet_ranges = wb[name]
df = pd.DataFrame(sheet_ranges.values)
df['x']['C'] = 10
df.to_excel("processing.xlsx", header=False, index=False)
df1 = pd.read_excel("processing.xlsx", sheetname=0, header=0)
df1.to_html('output.html')
With this code I am able to get fully functioning processing.xlsx but if I try to convert it into html the dataframe reads all formulas as NaN.
Question: How to force pandas to evaluate formulas of xlsx and not read them as NaN?
PS: If I try to convert initial.xlsx into html it works fine so something must be wrong in to_excel output.