POI操作Excel换行
来源:互联网 发布:mac桌面壁纸下载网站 编辑:程序博客网 时间:2024/06/11 02:44
网上很多博客操作Excel换行的都是Office2007之前的格式,一直没找到支持扩展名为.xlsx的换行方式,被折腾到要死,无奈之下只能去官网看看,发现了同时支持.xlsx和.xls两种扩展的。现在列出如下:
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((short)2); FileOutputStream fileOut = new FileOutputStream("ooxml-newlines.xlsx"); wb.write(fileOut); fileOut.close();
官网链接如下:
POI NewLinesInCells
阅读全文
0 0
- POI操作Excel换行
- poi excel 强制换行
- POI操作word 换行
- POI导出Excel强制换行
- POI操作EXCEL
- POI操作EXCEL
- POI操作Excel文档
- 使用POI操作Excel
- poi操作excel文件
- poi操作excel文件
- poi 操作Excel
- POI操作Excel
- POI 操作excel
- POI 操作EXCEL
- poi操作excel文件
- 用POI操作Excel
- poi操作excel
- poi 操作 excel
- jmeter入门——post请求上传附件
- nginx的反向代理及缓存功能。
- .jar !/.... FileNotFoundException解决方法
- ajax 返回前台数据
- 哈夫曼编码/译码器的实现
- POI操作Excel换行
- Airflow学习笔记 --- 运行Python Task
- 内存耗尽产生的crash: malloc: *** error for object 0x: pointer being reallocated was not allocated
- 鼠标事件
- JDK并发包(一)
- mysql 常用
- 拦截器和过滤器的区别
- 单例设计模式
- 毕业那年