作者:乔山办公网日期:
返回目录:excel表格制作
通过这个例百子,演示了如何度使用java生成以下问文件:导入Excel org。Apache POI。HSSF。用户答模型。*;进口回java.io.fileoutputstream;进口,;publicclass CreateCells { publicstaticvoid主要答(string [] args)抛出ioexcept
使用 poi ,具体实现
HSSFCellStyle style = null;
// 创建表e799bee5baa6e997aee7ad94e59b9ee7ad94338头style
HSSFCellStyle cellStyleTitle = workbook.createCellStyle();
cellStyleTitle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); // 填充单元格
cellStyleTitle.setFillForegroundColor(HSSFColor.YELLOW.index);
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// //居中显示
HSSFRow titleRow = sheet.createRow(0);
for (int i = 0; i < titles.length; i++) {
HSSFCell cell = titleRow.createCell(i);
// cell.setCellStyle(createCellColorStyle(workbook));
cell.setCellStyle(cellStyleTitle);
cell.setCellValue(titles[i]);// 给单元格赋值
}
不知道能,看懂不,如果有不清楚的私聊