Bug 64732 - XSSFSheet.createTable generates corrupted file when a header's cell contains a line break
Summary: XSSFSheet.createTable generates corrupted file when a header's cell contains ...
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 4.1.2-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2020-09-10 08:54 UTC by Olivier Levrey
Modified: 2021-12-21 15:17 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Levrey 2020-09-10 08:54:21 UTC
After calling XSSFSheet.createTable using an AreaReference with a cell containing a line break in a column header, the generated Excel file is corrupted.

Everything is described in detail here: https://stackoverflow.com/questions/63814180/apache-poi-createtable-generates-corrupted-file-when-a-headers-cell-contains-a
Comment 1 Nick Burch 2020-09-10 09:25:43 UTC
A quick check shows that XSSFDataValidation has code to do this encoding, and XSSFRichTextString has code to do the decoding

Would it make sense to pull that out to a util method (XMLHelper? StringUtil? other?) for re-use, then call that for the Table header case too?
Comment 2 PJ Fanning 2020-09-10 17:08:15 UTC
Hi Nick - sharing the code in a util makes sense
Comment 3 PJ Fanning 2020-09-10 17:10:18 UTC
XMLHelper would probably be a good place
Comment 4 PJ Fanning 2021-12-21 14:42:07 UTC
Added r1896246
Comment 5 PJ Fanning 2021-12-21 15:17:16 UTC
and r1896247