/**
 * 导出XSL文件
 * @param title 第一行表头
 * @param keys  表头对应的字段名
 * @param dataList resultList
 * @param xslName excelName
 * @throws WriteException 
 */
public void exportXslEntrys(String[] title, String[] keys, List dataList, String xslName) throws WriteException {

//获得导出的数据  
WritableWorkbook wbook = null ;
OutputStream out = null;
try {


//获得此时的系统时间,为本次导出的Excel表起表名
SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
String todayDate = sDateFormat.format(new Date());

this.getContext().getResponse().setHeader("Content-Type","application/vnd.ms-excel; charset=UTF-8");
//Excel表表名
String excelTableName=xslName+".xls";

String FileName = new String(excelTableName.getBytes("GBK"),"ISO8859_1");
this.getContext().getResponse().setHeader("Content-Disposition","attachment;filename=\"" + FileName + "\"");
out = this.getContext().getResponse().getOutputStream();
wbook = Workbook.createWorkbook(out); // 建立excel文件
// WritableSheet
WritableSheet wsheet = wbook.createSheet(xslName, 0); // 工作表名称
for(int i = 0; i < title.length;i++){
 wsheet.setColumnView(i, (int) 20);
}
// 设置Excel字体
WritableFont wfont = new WritableFont(WritableFont.ARIAL, 10,
WritableFont.BOLD, false,
jxl.format.UnderlineStyle.NO_UNDERLINE,
jxl.format.Colour.BLACK);

WritableCellFormat titleFormat = new WritableCellFormat(wfont);
WritableFont wfont1 = new WritableFont(WritableFont.ARIAL, 20,
WritableFont.BOLD, false,
jxl.format.UnderlineStyle.NO_UNDERLINE,
jxl.format.Colour.BLACK);
WritableCellFormat format1 = new WritableCellFormat(wfont1);

format1.setAlignment(jxl.format.Alignment.CENTRE);    

wsheet.mergeCells(0,0,title.length,0); 
Label excelTitle1 = new Label(0, 0, xslName, format1);
wsheet.addCell(excelTitle1);
titleFormat.setWrap(true);
// 设置Excel记录
for (int i = 0; i < title.length; i++) {

Label excelTitle = new Label(i, 1, title[i], titleFormat);
wsheet.addCell(excelTitle);
}
int size = dataList.size();
if(!dataList.isEmpty()){
for (int i = 0;  i < size; i++) {
Map map = (HashMap) dataList.get(i);
for (int j = 0; j < keys.length; j++) {
if(map.containsKey(keys[j])){
if(map.get(keys[j])!=null){
wsheet.addCell(new Label(j, i+2, map.get(keys[j]).toString()));

else
wsheet.addCell(new Label(j, i+2, ""));
}else{
wsheet.addCell(new Label(j, i+2, ""));
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
wbook.write();
wbook.close();
out.flush();
out.close();
System.gc();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} // 写入文件

}
this.getContext().dataResult.setMessage("OK");
}