Multiline text in Excel cells

后端 未结 2 1600
臣服心动
臣服心动 2021-01-01 09:08

I\'m trying to write multiline text to excel cells.

cell.setCellValue(\"line1 \\n line2\");

But when I open the document, I see only one li

2条回答
  •  执笔经年
    2021-01-01 09:50

    I found that you have to now include a third step after you follow the accepted answer to this question. You have to auto-size the column after you've added all of your data.

    Assuming you're concerned about column 2,

    sheet.autoSizeColumn(2);

    See this example from Apache for context. It works for me with Java 8, poi-3.15.jar, and Excel for Mac.

提交回复
热议问题