Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
df = pd.DataFrame(["test\ntest"])
df.to_excel("test.ods")
Issue Description
<table:table-cell office:value-type="string" office:string-value="test test"><text:p>test
test</text:p></table:table-cell>
I think, this is a bug in ODSWriter, which should convert \n to text:p
. Below are files from popular office applications:
- newline_office365.ods
- newline_libreoffice.ods
- newline_google.ods
And handlers in some ods readers: * https://git.sheetjs.com/sheetjs/sheetjs/src/branch/master/bits/80_parseods.js#L606 * https://github.com/miachm/SODS/blob/master/src/com/github/miachm/sods/OdsReader.java#L502 * https://github.com/ropensci/readODS/blob/7548c3ab8778efc2d6058fc56ca84920b2e3a92f/src/read_ods_internals.cpp#L43 * https://github.com/tafia/calamine/blob/master/src/ods.rs#L561
Originally posted by @dimastbk in https://github.com/pandas-dev/pandas/issues/53924#issuecomment-1746146698
Expected Behavior
Resave example in LibreOffice:
<table:table-cell office:value-type="string"><text:p>test<text:line-break/>test</text:p></table:table-cell>
Create an example in LibreOffice:
<table:table-cell office:value-type="string"><text:p>test</text:p><text:p>test</text:p></table:table-cell>
Comment From: dimastbk
Oops, I created this issue with "reference in new issue". Please, add the label "Bug".