When accessing cell values in Excel using openpyxl, you may encounter discrepancies between the displayed value and the actual value stored in the cell if the cell contains a formula. This is because openpyxl normally interprets the formula and retrieves the calculated result.
To retrieve the actual cell value, including formulas, you can use the data_only parameter when loading the workbook. This parameter instructs openpyxl to disregard any formulas and retrieve the uncalculated cell values.
wb = openpyxl.load_workbook(filename, data_only=True)
By setting data_only to True, you can retrieve the actual cell values even for cells containing formulas. This ensures that you always have access to the underlying values, regardless of any calculations that may have been applied.
免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。
Copyright© 2022 湘ICP备2022001581号-3