2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > 【poi第九节】poi操作excel 单元格的换行

【poi第九节】poi操作excel 单元格的换行

时间:2018-10-22 17:49:44

相关推荐

【poi第九节】poi操作excel 单元格的换行

poi操作excel 单元格的换行

import org.apache.poi.hssf.usermodel.HSSFWorkbook;import org.apache.poi.ss.usermodel.Cell;import org.apache.poi.ss.usermodel.CellStyle;import org.apache.poi.ss.usermodel.Row;import org.apache.poi.ss.usermodel.Sheet;import org.apache.poi.ss.usermodel.Workbook;import java.io.FileOutputStream;/*** @ClassName 类名:ExcelDemo9* @Author作者: hzh* @Date时间:/12/4 15:48* 换行**/public class ExcelDemo9 {public static void main(String[] args) throws Exception{//获得一个工作薄Workbook wb = new HSSFWorkbook();//第一个sheetSheet sheet = wb.createSheet("第一个sheet");//创建第一行Row row = sheet.createRow(1);//获取第一个单元格(第一列)Cell cell = row.createCell(5);//给第一个单元格赋值cell.setCellValue("第一个单元格的值 \n 我是下一行");CellStyle cellStyle = wb.createCellStyle();cellStyle.setWrapText(true);cell.setCellStyle(cellStyle);row.setHeightInPoints(2*sheet.getDefaultRowHeightInPoints());sheet.autoSizeColumn(2);FileOutputStream fileOutputStream = new FileOutputStream("D://file//huanhang.xls");wb.write(fileOutputStream);wb.close();}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。