我正在用java开发一个应用程序,我正在使用JXL
库。所以我尝试了这个:
File f = new File("test.xls");
ArrayList<String[]> ins = new ArrayList<String[]>();
for(int i=0;i<20;i++){
ins.add(new String[]{"-------"+i+"-------", "-------"+i+"-------", "-------"+i+"-------", i,"-------"+i+"-------", "-------"+i+"-------", "-------"+i+"-------","-------"+i+"-------", "-------"+i+"-------", "-------"+i+"-------", "-------"+i+"-------", "-------"+i+"-------", "-------"+i+"-------", "-------"+i+"-------"}); // JUST FOR EXAMPLE
}
WritableWorkbook workbook = Workbook.createWorkbook(f);
WritableSheet sheet = workbook.createSheet("TEST1", 0);
String[] headers = new String[]{"HEADER1", "HEADER2", "HEADER3", "HEADER4", "HEADER5", "HEADER6", "HEADER7", "HEADER8", "HEADER9", "HEADER10", "HEADER12"};
for(int i=0;i<headers.length;i++){
sheet.addCell(new Label(i, 0, headers[i]));
}
for(int i=0;i<ins.size();i++){
String tmp[] = ins.get(i);
for(int j=0;j<tmp.length;i++){
sheet.addCell(new Label(j,i+1,tmp[j].toString()));
}
}
workbook.write();
workbook.close();
}
当我启动它时,我检索:
Exception in thread "main" jxl.write.biff.RowsExceededException: The maximum number of rows permitted on a worksheet been exceeded
at jxl.write.biff.WritableSheetImpl.getRowRecord(WritableSheetImpl.java:1214)
at jxl.write.biff.WritableSheetImpl.addCell(WritableSheetImpl.java:1151)
at Pr1.main(Pr1.java:52)
Java Result: 1
我该如何解决?有可能我不能添加 21 行吗?这很奇怪……