该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
POI 3.7版本 在本地测试导出excel 都没有问题, 放到服务器上就出现下面的问题,
导出的excel文件打不开
求助大神~~~~
下面是我的代码
private boolean exportToExcel(List ds1ResultList) {
String filePath="/opt/scheduler/tomcat-report/webapps/scheduler/accessories/report/";
XMLProperties prop1 = XmlManage.getFile("/com/boco/eoms/report/config/report-info.xml");
String column = prop1.getProperty("kjh6.columnName");
String[] columns = column.split(",");
if(columns.length!=7){
return false;
}
String columnCnName;
String columnEnName;
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet();
XSSFRow row = sheet.createRow(0);
for (int i = 0; i < columns.length; i++) {
if(columns[i].split("\\$").length!=2){
return false;
}
columnCnName = StaticMethod.nullObject2String(columns[i].split("\\$")[0]);
XSSFCell cell = row.createCell(i);
cell.setCellValue(columnCnName);
}
ds1ResultList.size="+ds1ResultList.size());
for (int i = 0; i < ds1ResultList.size(); i++) {
XSSFRow cycleRow = sheet.createRow(i+1);
Map exportMap = (Map) ds1ResultList.get(i);
for (int j = 0; j < columns.length; j++) {
columnEnName = StaticMethod.nullObject2String(columns[j].split("\\$")[1]);
cycleRow.createCell(j).setCellValue(StaticMethod.nullObject2String(exportMap.get(columnEnName)));
}
}
BocoLog.info(this, "家客投诉未归档工单统计--数据写入excel完成");
Calendar c = Calendar.getInstance();
int month = 9;
FileOutputStream outputStream;
try {
outputStream = new FileOutputStream(filePath+"kjh6_"+month+".xlsx");
workbook.write(outputStream);
outputStream.close();
BocoLog.info(this, "75ftp数据文件推送开始");
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}