try{
//创建Excel
WritableWorkbookexportBook=Workbook.createWorkbook(os);
StringsheetName=excelExporter.getSheetName();
if(StringUtils.isNullString(sheetName)){
sheetName=fileName;
}
WritableSheetsheet=exportBook.createSheet(sheetName,0);
MapoutputColumnViews=newHashMap();
//数据头部区域
intcurRow=excelExporter.getDataRowXIndex();
Listheaders=excelExporter.getDataHeader();
if(null!=headers&&headers.size()>0){
curRow=insertRows(headers,curRow,excelExporter,sheet,outputColumnViews);
}

//循环文件填充数据
for(inti=0;i<fileList.size();i++){
Objectentity=fileList.get(i);
if(null==entity)
continue;
ListrowData=excelExporter.toDataBodyRow(entity,i);
curRow=insertRows(rowData,curRow,excelExporter,sheet,outputColumnViews);
}
//数据尾部区域
Listfooters=excelExporter.getDataFooter();
if(null!=footers&&footers.size()>0){
curRow=insertRows(footers,curRow,excelExporter,sheet,outputColumnViews);
}
if(!outputColumnViews.isEmpty()){
for(IteratorcolumnEntryIterator=outputColumnViews.entrySet().iterator();columnEntryIterator.hasNext();){
Map.EntrycolumnViewEntry=(Map.Entry)columnEntryIterator.next();
intcolumnIndex=newInteger((String)columnViewEntry.getKey()).intValue();
intwidth=((Integer)columnViewEntry.getValue()).intValue();
sheet.setColumnView(columnIndex,width);
}
}
exportBook.write();
exportBook.close();
}catch(Exceptionex){
thrownewBusinessException(ex);
}