public void importExcel() throws IOException, WriteException {
ArrayList<String[]> list1 = new ArrayList<>();
list1.add(new String[]{"1","user1","1"});
list1.add(new String[]{"2","user2","2"});
list1.add(new String[]{"3","user3","3"});
String[] title=new String[]{"序号","账户","密码"};
File file = new File("E:\\working\\account.xls");
if(file.exists()){
file.delete();
System.out.println("原有表格删除成功");
}
file.createNewFile();
WritableWorkbook workbook = Workbook.createWorkbook(file);
WritableSheet sheet1 = workbook.createSheet("sheet1", 0);
Label label=null;
for (int j = 0; j <title.length ; j++) {
label=new Label(j,0,title[j]);
sheet1.addCell(label);
}
int count=0;
for (int i=0;i<list1.size();i++) {
String[] oneh = list1.get(i);
count++;
label=new Label(0,count,oneh[0]);
sheet1.addCell(label);
label=new Label(1,count,oneh[1]);
sheet1.addCell(label);
label=new Label(2,count,oneh[2]);
sheet1.addCell(label);
}
workbook.write();
workbook.close();
log.info("导入user用户成功!!!!!!");
}