问答详情
源自:2-5 Excel实战之XSSF创建高版本Excel

为何Excel高版本会报NoClassDef?各种包也都引入了?

http://img.mukewang.com/591c76ed0001a07707490151.jpg

http://img.mukewang.com/591c76ee0001170603750370.jpg

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();

}

}


提问者:weibo_俄勒冈的微波炉_0 2017-05-18 00:17

个回答

  • 慕祈
    2017-05-21 10:12:45

    就是有jar包没有找到,找找看是不是有遗漏了