我用pio做數據導出表格的功能.但是導出的只是默認顯示的前十條數據.查詢之后導出的仍然是默認顯示的前十條數據.不是查詢出來的數據,請問是什么原因!!!!下面是我導出方法的代碼/**
?*?導出消費記錄
?*?
?*?@param?params
?*?@param?inParams
?*?@return
?*/
@RequestMapping(value?=?"/exportcustomerOrderList")
public?void?exportcustomerOrderList(Map<String,?Object>?params,
@RequestParam?Map<String,?Object>?inParams,HttpServletResponse?response)?{
PageBean?page?=?new?PageBean();
try?{
page.setPageNum(inParams.get("pageNum")?==?null???1?:?Integer
.parseInt(inParams.get("pageNum").toString()));
String?customerName?=?inParams.get("customerName")?==?null???""
:?inParams.get("customerName").toString();
String?recordName?=?inParams.get("recordName")?==?null???""
:?inParams.get("recordName").toString();
String?orderSN?=?inParams.get("orderSN")?==?null???""?:?inParams
.get("orderSN").toString();
String?orderStatus?=?inParams.get("orderStatus")?==?null???""
:?inParams.get("orderStatus").toString();
String?recordAccount?=?inParams.get("recordAccount")?==?null???""
:?inParams.get("recordAccount").toString();
String?billStatus?=?inParams.get("billStatus")?==?null???""
:?inParams.get("billStatus").toString();
//?************************時間戳新建功能*********************************
String?startTime?=?inParams.get("startTime")?==?null???""
:?inParams.get("startTime").toString();
System.out.println("startTime++++++++++++++++++++"?+?startTime);
String?endTime?=?inParams.get("endTime")?==?null???""?:?inParams
.get("endTime").toString();
System.out.println("endTime++++++++++++++++++++"?+?endTime);
//?*******************************************************************
Map<String,?Object>?param?=?new?HashMap<String,?Object>();
if?(!"".equals(billStatus))?{
param.put("billStatus",?billStatus);
}
if?(!"".equals(recordAccount))?{
param.put("recordAccount",?recordAccount);
}
if?(!customerName.equals(""))?{
param.put("customerName",?customerName);
}
if?(!recordName.equals(""))?{
param.put("recordName",?recordName);
}
if?(!orderSN.equals(""))?{
param.put("orderSN",?orderSN);
}
if?(!orderStatus.equals(""))?{
param.put("orderStatus",?orderStatus);
}
//?************************時間戳新建功能*********************************
if?(!startTime.equals(""))?{
param.put("startTime",?startTime);
}
if?(!endTime.equals(""))?{
param.put("endTime",?endTime);
}
//?*******************************************************************
if?(null?!=?inParams.get("paid"))?{
param.put("paid",?true);
}
List<Order>?list?=?orderService
.pagedQueryByParamsForOrderManagement(param,?page);
params.put("statuslist",?Arrays.asList(Order.Status.values()));
if?(null?!=?inParams.get("nopaystatus"))?{
params.put("nopaystatus",?true);
}
params.put("customerOrderList",?list);
params.put("page",?page);
params.put("customerName",?customerName);
params.put("recordName",?recordName);
if?(!"".equals(recordAccount))?{
params.put("recordName",
recordUserService.get(Integer.parseInt(recordAccount))
.getUserName());
}
params.put("orderSN",?orderSN);
params.put("orderStatus",?orderStatus);
List<Map<String,String>>?dataList=new?ArrayList<Map<String,String>>();
SimpleDateFormat?sdf=new?SimpleDateFormat("yyyy-MM-dd?HH:mm:ss");
for(Order?order:list){
Map<String,?String>?model=new?HashMap<String,?String>();
model.put("orderSn",?order.getOrderSn());
model.put("createdTime",?sdf.format(order.getCreatedTime()));
//訂單時間長度和結算時間
model.put("budgetMinutes",?order.minutesInfo(order.getBudgetMinutes())+"");
model.put("billMinutes",?order.minutesInfo(order.getBillMinutes())+"");
model.put("customerName",?order.getCustomer().getUserName());
model.put("statusLabel",?order.getStatusLabel());
dataList.add(model);
}
ExcelIOUtil?excelIOUtil=new?ExcelIOUtil();
excelIOUtil.exportcustomerOrderList(response,?dataList);
}?catch?(Exception?e)?{
e.printStackTrace();
}
}
//導出消費表格
public??void?exportcustomerOrderList(HttpServletResponse?response,?List<Map<String,String>>?list)?{
try?{
String?fileName?=?"消費表格.xls";
fileName?=?new?String(fileName.getBytes("GBK"),?"iso8859-1");
response.reset();
response.setHeader("Content-Disposition",?"attachment;filename="?+?fileName);//指定要輸出的文件名
response.setContentType("application/vnd.ms-excel");
response.setHeader("Pragma",?"no-cache");
response.setHeader("Cache-Control",?"no-cache");
response.setDateHeader("Expires",?0);
OutputStream?output?=?response.getOutputStream();
BufferedOutputStream?bufferedOutPut?=?new?BufferedOutputStream(output);
System.out.println("__________________________________________");
//工作表名
String?worksheet?=?"sheet1";
HSSFWorkbook?wb?=?new?HSSFWorkbook();
HSSFSheet?sheet?=?wb.createSheet(worksheet);
//創建列標頭LIST
List<String>?titleList?=?new?ArrayList<String>();
//titleList.add("ID");?????//visId
??//name
titleList.add("訂單編號");
titleList.add("創建時間");
titleList.add("預計時長");
titleList.add("計算時長");
titleList.add("客戶");
titleList.add("處理狀態");
//?創建單元格樣式
HSSFCellStyle?cellStyleTitle?=?wb.createCellStyle();
//?指定單元格水平居中對齊
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
//?指定單元格垂直居中對齊
cellStyleTitle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
//?指定當單元格內容顯示不下時自動換行
cellStyleTitle.setWrapText(true);
//------------------------------------------------------------------
HSSFCellStyle?cellStyle?=?wb.createCellStyle();
//?指定單元格居中對齊
cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
//?指定單元格垂直居中對齊
cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
//?指定當單元格內容顯示不下時自動換行
cellStyle.setWrapText(true);
//------------------------------------------------------------------
//?設置單元格字體
HSSFFont?font?=?wb.createFont();
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontName("宋體");
font.setFontHeight((short)?200);
cellStyleTitle.setFont(font);
//==================================================================
//定義第一行
HSSFRow?row?=?sheet.createRow(0);
HSSFCell?cell?=?null;
for?(int?i?=?0;?i?<?titleList.size();?i++)?{
cell?=?row.createCell((short)i);
cell.setCellStyle(cellStyleTitle);
cell.setCellValue(new?HSSFRichTextString(titleList.get(i)));
}
int?rowNumber?=?1;
for?(Map<String,?String>?map?:?list)?{
row?=?sheet.createRow(rowNumber);
cell.setCellStyle(cellStyle);
int?num=0;
cell?=?row.createCell((short)num++);
cell.setCellValue(new?HSSFRichTextString(map.get("orderSn")));
cell?=?row.createCell((short)num++);
cell.setCellValue(new?HSSFRichTextString(map.get("createdTime")));
cell?=?row.createCell((short)num++);
cell.setCellValue(new?HSSFRichTextString(map.get("budgetMinutes")));
cell?=?row.createCell((short)num++);
cell.setCellValue(new?HSSFRichTextString(map.get("billMinutes")));
cell?=?row.createCell((short)num++);
cell.setCellValue(new?HSSFRichTextString(map.get("customerName")));
cell?=?row.createCell((short)num++);
cell.setCellValue(new?HSSFRichTextString(map.get("statusLabel")));
rowNumber++;
}
wb.write(bufferedOutPut);
bufferedOutPut.flush();
bufferedOutPut.close();
wb.removeSheetAt(0);
}?catch?(IOException?e)?{
e.printStackTrace();
}?finally?{
list.clear();
}
}其他就不一一列舉了,求大神告知癥狀所在!!!!!
3 回答

啊丶木木
TA貢獻121條經驗 獲得超119個贊
問題解決了./關鍵在于前段獲取的form表單值傳遞給了查詢,而我的導出是另外的input標簽.沒有form傳值.解決方法就是把值傳給導出的方法.可以用ajax方法傳入/或者在jsp界面寫個方法,拼字段,把值傳給后臺導出方法
//導出 ?function?exportModel(){ ??var?temp?=?[], ? tepString?=?''; ???$.each($('.form-inline?input,.form-inline?select'),function(k,v){ ? temp.push(v.value); }); ???tepString?=?'?userName='+temp[0]+'&type'+temp[1]; ???console.log(temp); ???console.log(tepString); ??window.location.href="<%=request.getContextPath()%>/market/exportcustomerList"+tepString; ???????????}
類似為這種
添加回答
舉報
0/150
提交
取消