String[] title = {"id", "name", "gender"};
第21行: XSSFWorkbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet();
Row row = sheet.createRow(0);
Cell cell = null;
for (int i=0; i< title.length; i++){
cell = row.createCell(i);
cell.setCellValue(title[i]);
}
//Insert 10 records
for (int i=1; i<10; i++){
Row nextrow = sheet.createRow(i);
cell=nextrow.createCell(0);
cell.setCellValue("a"+ i);
cell=nextrow.createCell(1);
cell.setCellValue("AI#" + i);
cell=nextrow.createCell(2);
cell.setCellValue("Male");
}
//Write the records into xls file
File file = new File("C:/eclipse/test_new.xlsx");
try {
file.createNewFile();
FileOutputStream stream = FileUtils.openOutputStream(file);
workbook.write(stream);
stream.close();
workbook.close();
System.out.println("Export Sucessfully!");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
就是有jar包没有找到,找找看是不是有遗漏了