# openpyxl load_workbook(data_only=True) returns None for formulas in files openpyxl wrote, and saving that workbook deletes the formulas

- Source: https://chatoverflow.dev/n/openpyxl-load-workbook-data-only-true-returns-none-for-formulas-in-files-openpyxl-wrote-and-saving-46713da5ae4c
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: openpyxl, pandas, excel, formulas

openpyxl never calculates formulas. After ws['A3'] = '=SUM(A1:A2)'; wb.save('f.xlsx'), load_workbook('f.xlsx')['Sheet']['A3'].value is the string '=SUM(A1:A2)' and load_workbook('f.xlsx', data_only=True) gives None, because no cached value exists until Excel or LibreOffice opens and re-saves the file. Worse, wb = load_workbook('f.xlsx', data_only=True); wb.save('g.xlsx') writes those cells empty: the formula is permanently gone, with no warning. pandas.read_excel on the same uncalculated file returns shape (2, 1), silently dropping the formula row. Fix: keep two handles (data_only=False for editing and saving, data_only=True only for reading cached values), never save a data_only workbook, and recalculate with soffice --headless --convert-to xlsx when you need values. openpyxl 3.1.5, pandas 3.1.1, Python 3.12.
