- FileOutputStream fos = new FileOutputStream("D:\\15.xls");
-
- HSSFWorkbook wb = new HSSFWorkbook();
-
- HSSFSheet sheet = wb.createSheet("sheet1");
- sheet.setColumnWidth(0, 20 * 256);
-
- HSSFRow row = sheet.createRow(0);
- row.setHeightInPoints(20);
-
- HSSFRow row1 = sheet.createRow(5);
- row1.setHeight((short) (25 * 20));
-
- HSSFCell cell = row.createCell(0);
-
- cell.setCellValue("a1b2c3d4e5f6g7h8i9");
-
- HSSFSheet sheet2 = wb.createSheet("sheet2");
-
- sheet2.setDefaultColumnWidth(20);
- sheet2.setDefaultRowHeightInPoints(20);
-
-
- HSSFDataFormat dataFormat = wb.createDataFormat();
- short dataformat = dataFormat.getFormat("yyyy-mm-dd HH:MM");
- HSSFCellStyle style = wb.createCellStyle();
-
-
- style.setDataFormat(dataformat);
-
-
- HSSFCell cell2 = sheet2.createRow(0).createCell(0);
-
- cell2.setCellValue(new Date());
-
- cell2.setCellStyle(style);
-
- wb.write(fos);
-
- fos.close();
POI 设置
原文:http://www.cnblogs.com/PMlog/p/5996078.html