pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.85k stars 18.01k forks source link

BUG: incorrect handling of line breaks in OdsWriter #55728

Open dimastbk opened 1 year ago

dimastbk commented 1 year ago

Pandas version checks

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&#10;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:

And handlers in some ods readers:

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>
dimastbk commented 1 year ago

Oops, I created this issue with "reference in new issue". Please, add the label "Bug".