Java ApachePOI非常慢
我正在尝试导出xls文件。但由于某些原因,ApachePOI非常慢。我看不到任何日志,因此日志记录似乎已关闭。这是我的密码。导出不太大的数据(3000行)。WebSpherePortal7.0。请帮忙Java ApachePOI非常慢,java,excel,apache,logging,apache-poi,Java,Excel,Apache,Logging,Apache Poi,我正在尝试导出xls文件。但由于某些原因,ApachePOI非常慢。我看不到任何日志,因此日志记录似乎已关闭。这是我的密码。导出不太大的数据(3000行)。WebSpherePortal7.0。请帮忙 if (divideBySchool==null || (!sessionApplicationTypeId.equals(PROGRAM_DIRECT) && !sessionApplicationTypeId.equals(PROGRAM_FOUNDATION) &&a
if (divideBySchool==null || (!sessionApplicationTypeId.equals(PROGRAM_DIRECT) && !sessionApplicationTypeId.equals(PROGRAM_FOUNDATION) && !sessionApplicationTypeId.equals(PROGRAM_TRANSFER))){
List<RField> formFields = sbLocal.getFieldsByApplicationType(sessionApplicationTypeId, fieldsToTake);
int colNum=2;
int rowNum=0;
org.apache.poi.ss.usermodel.Row headerRow = sheet.createRow(rowNum);
org.apache.poi.ss.usermodel.Cell cell = headerRow.createCell(1);
cell.setCellValue("Applicant ID");
cell.setCellStyle(styles.get("header"));
sheet.setColumnWidth(1, 256*25);
for (RField rField : formFields) {
cell = headerRow.createCell(colNum);
cell.setCellValue(rField.getName());
cell.setCellStyle(styles.get("header"));
sheet.setColumnWidth(colNum, 256*25);
colNum++;
}
cell = headerRow.createCell(colNum);
cell.setCellValue("Applicant status");
cell.setCellStyle(styles.get("header"));
sheet.setColumnWidth(colNum, 256*25);
if (fieldsToTake.equals(IN_EXAM)){
cell = headerRow.createCell(colNum+1);
cell.setCellValue("Exam status");
cell.setCellStyle(styles.get("header"));
sheet.setColumnWidth(colNum, 256*25);
cell = headerRow.createCell(colNum+2);
cell.setCellValue("Note");
cell.setCellStyle(styles.get("header"));
sheet.setColumnWidth(colNum, 256*25);
}
System.out.println("Time for label ==============>" + (System.currentTimeMillis() - start));
start = System.currentTimeMillis();
rowNum++;
int k=1;
for (int i = 0; i < applicants.length(); i++) {
headerRow = sheet.createRow(rowNum);
cell = headerRow.createCell(0);
cell.setCellValue(String.valueOf(k));
//dataCell.setCellStyle(styles.get("cell_normal"));
cell = headerRow.createCell(1);
cell.setCellValue(applicants.getJSONObject(i).getString("APPLICANT_ID"));
//dataCell.setCellStyle(styles.get("cell_normal"));
colNum=2;
for (RField rField : formFields) {
if (applicants.getJSONObject(i).has(String.valueOf(rField.getFieldId()))){
//rField.getRFieldType().getFieldTypeId()
String value = applicants.getJSONObject(i).getString(String.valueOf(rField.getFieldId()));
if(rField.getRFieldType().getFieldTypeId() == 3 && rField.getFieldId() != 797){
value = value.split(" ")[0];
}
cell = headerRow.createCell(colNum);
cell.setCellValue(value);
//dataCell.setCellStyle(styles.get("cell_normal"));
} else{
cell = headerRow.createCell(colNum);
cell.setCellValue("");
//dataCell.setCellStyle(styles.get("cell_normal"));
}
colNum++;
}
if (!applicants.getJSONObject(i).isNull("APPLICANT_STATUS")){
cell = headerRow.createCell(colNum);
cell.setCellValue(applicants.getJSONObject(i).getString("APPLICANT_STATUS"));
////dataCell.setCellStyle(styles.get("cell_normal"));
}
else{
cell = headerRow.createCell(colNum);
cell.setCellValue("");
//dataCell.setCellStyle(styles.get("cell_normal"));
}
if (fieldsToTake.equals(IN_EXAM)){
if (applicants.getJSONObject(i).has("EXAM_STATUS_NAME")){
cell = headerRow.createCell(colNum+1);
cell.setCellValue(applicants.getJSONObject(i).getString("EXAM_STATUS_NAME"));
//dataCell.setCellStyle(styles.get("cell_normal"));
//sheet.addCell(new Label(colNum+1, rowNum, applicants.getJSONObject(i).getString("EXAM_STATUS_NAME"), cellFormat));
} else{
cell = headerRow.createCell(colNum+1);
cell.setCellValue("");
//dataCell.setCellStyle(styles.get("cell_normal"));
//sheet.addCell(new Label(colNum+1, rowNum, "", cellForm));
}
if (applicants.getJSONObject(i).has("NOTE")){
colNum++;
cell = headerRow.createCell(colNum+2);
cell.setCellValue(applicants.getJSONObject(i).getString("NOTE"));
//dataCell.setCellStyle(styles.get("cell_normal"));
//sheet.addCell(new Label(colNum+2, rowNum, applicants.getJSONObject(i).getString("NOTE"), cellFormat));
}else{
cell = headerRow.createCell(colNum+2);
cell.setCellValue("");
//dataCell.setCellStyle(styles.get("cell_normal"));
//sheet.addCell(new Label(colNum+2, rowNum, "", cellForm));
}
}
rowNum++;
k++;
}
System.out.println("Time for filling ==============>" + (System.currentTimeMillis() - start));
if(divideBySchool==null | | |(!sessionApplicationTypeId.equals(PROGRAM_DIRECT)&&&!sessionApplicationTypeId.equals(PROGRAM_FOUNDATION)&&&!sessionApplicationTypeId.equals(PROGRAM_TRANSFER))){
List formFields=sbLocal.getfieldsbyaapplicationtype(sessionApplicationTypeId,fieldsToTake);
int colNum=2;
int rowNum=0;
org.apache.poi.ss.usermodel.Row headerRow=sheet.createRow(rowNum);
org.apache.poi.ss.usermodel.Cell Cell=headerRow.createCell(1);
cell.setCellValue(“申请人ID”);
cell.setCellStyle(styles.get(“header”);
页。设置柱宽(1,256*25);
用于(RField RField:formFields){
cell=headerRow.createCell(colNum);
cell.setCellValue(rField.getName());
cell.setCellStyle(styles.get(“header”);
表1.setColumnWidth(colNum,256*25);
colNum++;
}
cell=headerRow.createCell(colNum);
cell.setCellValue(“申请人状态”);
cell.setCellStyle(styles.get(“header”);
表1.setColumnWidth(colNum,256*25);
if(fieldsToTake.equals(IN_考试)){
cell=headerRow.createCell(colNum+1);
cell.setCellValue(“检查状态”);
cell.setCellStyle(styles.get(“header”);
表1.setColumnWidth(colNum,256*25);
cell=headerRow.createCell(colNum+2);
cell.setCellValue(“注释”);
cell.setCellStyle(styles.get(“header”);
表1.setColumnWidth(colNum,256*25);
}
System.out.println(“标签时间==============>”+(System.currentTimeMillis()-start));
start=System.currentTimeMillis();
rowNum++;
int k=1;
对于(int i=0;i