作者:乔山办公网日期:
返回目录:excel表格制作
通过这个例子,演示了如何使用java生成以下文件:导入Excel org。Apache POI。HSSF。用户模型。*;进口java.io.fileoutputstream;进口,;publicclass CreateCells 。
publicstaticvoid主要(string [] args)抛出ioexcept。
使用 poi ,具体实现
HSSFCellStyle style = null;
// 创建表头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]);// 给单元格赋值
}
不知道能,看懂e68a84e8a2ade799bee5baa6e997aee7ad94338不,如果有不清楚的私聊
使用 poi ,具体实现e799bee5baa6e79fa5e98193e78988e69d83364
HSSFCellStyle style = null;
// 创建表头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]);// 给单元格赋值
}
不知道能,看懂不,如果有不清楚的私聊