java代码
String saveFilePath = conf.get("down.url") + "/" ;
Workbook workbook=new XSSFWorkbook();
Sheet sheet1=workbook.createSheet("结果总数拦截记录");
JSONObject head=new JSONObject();
head.put("deptname","科室名称");
head.put("fzyh","住院号");
List<String> props=Arrays.asList("deptname","fzyh");
JSONObject obj1=getDeptShjlDetails(happenDate,strDate,endDate,null,"结果总数",ruletype,null,null,null,null,"","",gzlx);
JSONArray arr1=obj1.getJSONArray("list");
Row row=sheet1.createRow(0);
for(int j=0;j<props.size();j++){
Cell cell=row.createCell(j);
cell.setCellValue(head.getString(props.get(j)));
}
for(int i=0;i<arr1.size();i++){
Row rowData=sheet1.createRow(i+1);
for(int j=0;j<props.size();j++){
Cell cell=rowData.createCell(j);
Record record= (Record) arr1.get(i);
cell.setCellValue(record.getString(props.get(j)));
}
}
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
String fileName="全部科室拦截记录.xlsx";
File file=new File(saveFilePath+"/"+sdf.format(new Date()),fileName);
if(!file.exists()){
File dirFile = new File(file.getParent());
if(!dirFile.exists()){
dirFile.mkdirs();
}
file.createNewFile();
}
FileOutputStream outputStream=new FileOutputStream(file);
workbook.write(outputStream);
workbook.close();
outputStream.close();