Closed buzMartin closed 1 year ago
Thanks for the bug report.
You can turn off the XlsxWriter option to automatically convert strings starting with "=" to into formulas by using the strings_to_formulas
Constructor option.
You can pass it to pandas like this:
import pandas as pd
df = pd.DataFrame(data={"a": ["====new line===", ""], "b": ["", ""]})
writer = pd.ExcelWriter('test.xlsx',
engine='xlsxwriter',
engine_kwargs={'options': {'strings_to_formulas': False}})
df.to_excel(writer)
writer.book.close()
Output:
Thanks! That's great
Current behavior
I have a workbook contains strings like below: "=======new line=====" Then use pandas read this workbook and write with xlsxwriter. The file turns out corrupt. I have tested many times, if I use xlsxwriter as pandas engine, it cannot write this kind of string in the right way. Of course I can manipulate the dataframe and add a single quote at the begining for each strings that start with "==", but it's not a good choice.
Expected behavior
If some strings start with "==", I hope the code below still works and will give me an excel file that not corrupted.
Sample code to reproduce
Environment
Any other information
No response
OpenOffice and LibreOffice users