public String download() throws Exception { LogWriter.println(this.getClass().toString() + ":download下的方法被调用了"); // 创建新的ExportExcel类以创建excel ExportExcel<YearCountTaxModel> ex = new ExportExcel<YearCountTaxModel>(new YearCountTaxModel()); // SXSSFWorkbook workbook = new SXSSFWorkbook(300); if (getSessionUser() == null) { return "noSession"; } // 获取记录总数,这里除以40000是为什么 long count = yearCountTaxService.getAllMessageCount( user.getUpperDistrict() + user.getDistrictName(), beginyear, endyear) / 40000 + 1; LogWriter.println("获取的记录数位:" + count); for (int i = 0; i < count; ++i) { getAllList(i * 40000, 40000); // 获取需要下载的数据list // 获取需要下载的数据list workbook = ex.creatExcel(workbook, analyList); } // 创建输出流 excelFile = ex.downLoadExcel(workbook); systemLogService.insertSystemLog("3", "下载按年度统计纳税征缴情况", true); return "excel"; }
public String getAllYearCountTaxByPage() { // 但是初始显示的时候 不应该是全部 if (beginyear == null) { beginyear = "2011"; } else { LogWriter.println("前台传给后台的数据beginyear为:" + beginyear); } if (endyear == null) { endyear = "2013"; } else { LogWriter.println("前台传给后台的数据endyear为:" + endyear); } if (getSessionUser() == null) { return "noSession"; } LogWriter.println("用户上级地区:" + user.getUpperDistrict() + "用户本级地区:" + user.getDistrictName()); try { recordCount = yearCountTaxService.getAllMessageCount( user.getUpperDistrict() + user.getDistrictName(), beginyear, endyear); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); json = "请检查是否存在相应的数据库模式"; return "jsonData"; } if (recordCount != 0) { int count = (int) (recordCount / pageSize); pageCount = ((recordCount % pageSize) == 0) ? count : count + 1; // 计算总页数 } yearCountTaxList = yearCountTaxService.getAllMessageByPage( pageNum, pageSize, user.getUpperDistrict() + user.getDistrictName(), beginyear, endyear); return "showLessTaxMessage"; }
public String getDownloadFileName() { SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd "); String downloadFileName = "按年度统计纳税征缴情况" + user.getUpperDistrict() + user.getDistrictName() + sf.format(new Date()).toString() + ".xlsx"; try { downloadFileName = new String(downloadFileName.getBytes("GBK"), "ISO8859-1"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return downloadFileName; }
/** * 得到数据 * * @param startnum 数据开始的下标 * @param totalnum 传过来的数据总数 */ public void getAllList(int startnum, int totalnum) { String dis = user.getUpperDistrict() + user.getDistrictName(); // analyList = yearCountTaxService.getExcelList(dis, beginyear, endyear, startnum, totalnum); }