Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 HSSF 工作簿使用 java 将数据写入 excel,现在我有一个包含 n-no 个单词的列名,如果我通常将其插入同一行,我想将句子分成两个不同的行和插入同一个单元格。
下面是我用来设置列的代码
rowhead.createCell((short) 0).setCellValue("Hi there it is my lengthy column please help");
谢谢,汤姆
您只需使用 Java'\n'换行符将句子分成 2 行,然后设置WrapText为true:
'\n'
WrapText
true
Cell cell = rowhead.createCell((short) 0)); cell.setCellValue("Hi there it is my lengthy \n column please help"); CellStyle cs = wb.createCellStyle(); cs.setWrapText(true); cell.setCellStyle(cs);