How can I see the formulas of an excel spreadsheet in pandas / python? How can I see the formulas of an excel spreadsheet in pandas / python? pandas pandas

How can I see the formulas of an excel spreadsheet in pandas / python?


OpenPyXL provides this capacity out-of-the-box. See here and here. An example:

from openpyxl import load_workbookimport pandas as pdwb = load_workbook(filename = 'empty_book.xlsx')sheet_names = wb.get_sheet_names()name = sheet_names[0]sheet_ranges = wb[name]df = pd.DataFrame(sheet_ranges.values)


Yes, it is possible. I recently found a package that solves this issue in a quite sophisticated way. It is called portable-spreadsheet (available via pip install portable-spreadsheet). It basically encapsulates xlsxwriter. Here is a simple example:

import portable_spreadsheet as pssheet = ps.Spreadsheet.create_new_sheet(5, 5)# Set valuessheet.iloc[0, 0] = 25  # Set A1sheet.iloc[1, 0] = sheet.iloc[0, 0]  # reference to A1# Export to Excelsheet.to_excel('output/sample.xlsx')

It works in a similar way as Pandas Dataframe.