I posted this a while ago on
SO, too, but no luck, maybe someone here will be able to help?
Issue:
- For some string input, this creates broken .xlsx files that need to be repaired. (*problem with some content* --- *removed formula*, cf error msg below)
- I assume this happens because Excel interprets the cell content not as a string, but a formula which it cannot parse, e.g. when a string value starts with "="
Question:- When using xlsxwriter as engine, I can solve this issue by setting the argument `options = {"strings_to_formulas" : False }`
- Is there a similar argument for openpyxl?
Troubleshooting:- I found the `
data_only` argument to Workbook, but it only seems to apply to reading files / I cannot get it to work with ExcelWriter().
- Not all output values are strings / I'd like to avoid converting all output to str
- Could not find an applicable question on here
Any hints are much appreciated, thanks!
----
Error messages:
*We found a problem with some content in 'file.xlsx'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes*
The log after opening says:
*[...] summary="Following is a list of removed records:"><removedRecord>Removed Records: Formula from /xl/worksheets/sheet1.xml part [...]*
Code import pandas
excelout = pandas.ExcelWriter(output_file, engine = "openpyxl")
df.to_excel(excelout)
excelout.save()
Versions:
pandas @0.24.2
openpyxl @2.5.6
Excel 2016 for Mac (but replicates on Win)