这么写试试
"参数内容"+(char)11+"换行"
"参数内容"+(char)11+"换行"
解决方案 »
- Struts2框架中 动态页面的值在验证不通过的情况下,怎么保存的问题,望各位高人指教~
- struts2 <s:iterator></s:iterator>如何自身2次迭代
- 高手进 (spring+hibernate 生成表)
- jsp session共享问题
- 如何获得请求的url?
- 如何在JSP页面上弹出javascript的对话框
- 一个jsp开发弱问题
- 高手指点 请问:以下是什么原因??(Thank you!!!)
- sevlet中如何取得对应jsp中的pageContext
- 大家帮我看看这段jsp程序哪里错了?(HOT!在线等待答对就给分)
- [求助]java课程设计的问题
- springMVC提示No mapping found for HTTP request错误
* How to use newlines in cells
*/
public class NewLinesInCells { public static void main(String[]args) throws Exception {
Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet(); Row row = sheet.createRow(2);
Cell cell = row.createCell(2);
cell.setCellValue("Use \n with word wrap on to create a new line"); //to enable newlines you need set a cell styles with wrap=true
CellStyle cs = wb.createCellStyle();
cs.setWrapText(true);
cell.setCellStyle(cs); //increase row height to accomodate two lines of text
row.setHeightInPoints((2*sheet.getDefaultRowHeightInPoints())); //adjust column width to fit the content
sheet.autoSizeColumn(2); FileOutputStream fileOut = new FileOutputStream("ooxml-newlines.xlsx");
wb.write(fileOut);
fileOut.close();
}}
应该可以的
http://stackoverflow.com/questions/7477335/java-apache-poi-newline-characters-are-ignored-when-writing-to-xwpftable-cell
XWPFParagraph para = row.getCell(i).getParagraphs().get(0);
for(String text : myStrings){
XWPFRun run = para.createRun();
run.setText(text.trim());
run.addBreak();
}
不过感觉有点繁琐,每次都要来个循环大家平时导出word用什么第三方的API?