单元格样式"/>
hssfrow 单元格样式
导出一个人员Excel表格,代码如下,制作例子说明,可以直接复制:
public static void main(String[] args) throws IOException {
HSSFWorkbook book = new HSSFWorkbook();
HSSFSheet sheet = book.createSheet("Info");
HSSFRow header = sheet.createRow(0);
header.createCell(0).setCellValue("序号");
header.createCell(1).setCellValue("学号");
header.createCell(2).setCellValue("姓名");
header.createCell(3).setCellValue("年龄");
header.createCell(4).setCellValue("人员标编号");
header.createCell(5).setCellValue("地址");
header.createCell(6).setCellValue("电话");
header = sheet.createRow(1);
header.createCell(0).setCellValue("1");
header.createCell(1).setCellValue("1");
header.createCell(2).setCellValue("张三");
header.createCell(3).setCellValue("18");
header.createCell(4).setCellValue("00001");
header.createCell(5).setCellValue("一街二号");
header.createCell(6).setCellValue("1234567890");
FileOutputStream fos;
try {
fos = new FileOutputStream("d:/test.xls");
book.write(fos);
fos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
更多推荐
hssfrow 单元格样式
发布评论