如何将使用 Xlsx writer 创建的论坛的值读入 Pandas 数据框?

How to read in values from forumales created with Xlsx writer into Pandas dataframe?

我有 excel 个使用 Xlsxwriter 生成的包含公式的电子表格。当我尝试将 excel 读回 pandas 数据帧时,它会读取值 0 而不是单元格中公式的计算值。有没有办法将实际计算的公式值读入pandas?

Is there a way to read in the actual calculated formula value into pandas?

如果 xlsx 文件是使用 XlsxWriter 创建的,则不会。

来自 XlsxWriter FAQ:

Q. Why do my formulas show a zero result in some, non-Excel applications?

Due to wide range of possible formulas and interdependencies between them XlsxWriter doesn’t, and realistically cannot, calculate the result of a formula when it is written to an XLSX file. Instead, it stores the value 0 as the formula result. It then sets a global flag in the XLSX file to say that all formulas and functions should be recalculated when the file is opened.

This is the method recommended in the Excel documentation and in general it works fine with spreadsheet applications. However, applications that don’t have a facility to calculate formulas, such as Excel Viewer, or several mobile applications, will only display the 0 results.