When outputting EXCEL using SXSSF Workbook, Use ver poi-3.17 or later. that's all.
Below, I will leave it as a memo if you absolutely must use poi-3.16.
When using SXSSFWorkbook, if a character string with a line feed code of CRLF is set in a cell, an EXCEL file with double the number of line breaks in the cell is generated. When using a version other than the above memory-saving version, CRLF line breaks do not double.
When using SXSSFWorkbook, if the line feed code of the character string to be set in the cell is CRLF, set it to CR only or LF only before passing it.
Untested example
SXSSFWorkbook wb = new SXSSFWorkbook();
// Abbreviation
String setString = "1st line \ r \ n2nd line";
Row row = sheet1.createRow(rowNum);
Cell cell = row.createCell(colNum);
cell.setCellValue(setString.replaceAll("\r\n", "\n"));
Grep the source with'\ r'to find out. Scan character by character with the switch of org.apache.poi.xssf.streaming.SheetDataWriter, Because'\ r'and'\ n'are converted to line breaks respectively. Missing consideration of "\ r \ n".
Even poi-3.16 didn't fix it.
that's all.
It seems to have been fixed in 3.17. Thank you to @ yuki-teraoka for pointing this out.
Bugzilla: Bug 61048 - Newlines in cells not rendering with SXSSF github: [Bug-61048] SXSSF module writes wrong escape sequence for carriage re…
Recommended Posts