@RequestMapping(value = "/generateReport.do")
	public ModelAndView generateReport(String txnType, String startDate,
			String endDate, String fileName, HttpServletRequest request,
			HttpServletResponse response) {

		// 传递是否是admin到页面
		HttpSession session = request.getSession();
		Users u = (Users) session.getAttribute(Constants.LOGIN_USER);
		if (!u.isAdmin())
			return new ModelAndView("redirect:login.do");

		if (txnType == null || startDate == null || endDate == null
				|| fileName == null) {
			ModelAndView mav = new ModelAndView("TxnReport");
			mav.addObject("reportTitle", "销售");
			mav.addObject("txnType", "sale");
			return mav;
		}

		logger.debug("start to parse start and end date...");
		Date start = null, end = null;
		if (startDate != null && endDate != null) {
			try {
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				start = sdf.parse(startDate);
				end = sdf.parse(endDate);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		logger.debug("start to generate excel report...");

		List<Transaction> txns = txnService.queryByDateRangeAndTxnType(txnType,
				start, end);

		// logger.debug("get query result, transaction size : " + txns.size());

		response.setContentType("application/binary;charset=UTF-8");

		ServletOutputStream outputStream = null;

		try {
			fileName = new String((fileName).getBytes(), "ISO8859_1");

			response.setHeader("Content-disposition", "attachment; filename="
					+ fileName + ".xlsx");// 组装附件名称和格式
			outputStream = response.getOutputStream();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		exportExcel(txns, txnType, fileName, outputStream);

		return enterReport(txnType, request);
	}