pio导excel问题,导出数据不对!!!!

我用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();
		}
	}

其他就不一一列举了,求大神告知症状所在!!!!!

啊丶木木
浏览 2364回答 3
3回答

啊丶木木

还有只到10条数据,是因为查询用的是分页查询和显示,.在导出的方法里重新写个查询条件,把分页查询去掉就可以了

啊丶木木

问题解决了./关键在于前段获取的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;            }类似为这种

嗨子

你是不是就查询10条数据呢
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java