引言:最近对于Excel 的导出接触的比较多,一直也没有系统的去整理,在此做一个简单的整理,先说如何向Excel中追加数据,至于Excel的导出、导入会在下几篇篇文章中详细描述。希望够共同学习。ok,直接上代码:
public static void main(String[] args) {
String filePath="D:\\test.xls";
// 输出流
try {
FileInputStream is = new FileInputStream(filePath);
Workbook wb =getWorkbook(is);
System.out.println("aaa");
Sheet sheet1 = wb.getSheetAt(0);
System.out.println(sheet1.getLastRowNum());
Row row = sheet1.createRow(sheet1.getLastRowNum() + 1);
row.setHeightInPoints((short) 25);
// 给这一行赋值
row.createCell(0).setCellValue("12");
row.createCell(1).setCellValue("23");
FileOutputStream os = new FileOutputStream(filePath);
wb.write(os);
is.close();
os.close();
} catch (Exception