コード例 #1
0
 // 月度资金计划导出
 public void exportFundData(HttpServletRequest request, HttpServletResponse response)
     throws IOException, ExcelPortException, DbPropertyException, SQLException {
   String sjType = request.getParameter("sjType") == null ? "" : request.getParameter("sjType");
   String unitId = request.getParameter("unitId") == null ? "" : request.getParameter("unitId");
   String businessType =
       request.getParameter("businessType") == null ? "" : request.getParameter("businessType");
   String reportId =
       request.getParameter("reportId") == null ? "" : request.getParameter("reportId");
   InputStream templateIn = investmentPlanService.getExcelTemplate(businessType);
   if (templateIn != null) {
     ByteArrayOutputStream outStream =
         fundMonthPlanService.exportFundData(sjType, unitId, businessType, reportId);
     String fileName = "月度资金计划数据_" + unitId + "_" + sjType + ".xls";
     response.setContentType("application/octet-stream");
     response.setHeader(
         "Content-Disposition",
         "attachment; filename=" + new String(fileName.getBytes("gb2312"), "ISO8859-1"));
     OutputStream out = response.getOutputStream();
     out.write(outStream.toByteArray());
     out.flush();
     out.close();
   } else {
     System.out.println("没有相关的模板信息!");
   }
 }
コード例 #2
0
  // ********************************************* 数据导出
  // *****************************************************************
  public void exportData(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ExcelPortException, DbPropertyException, SQLException {
    String sjType = request.getParameter("sjType") == null ? "" : request.getParameter("sjType");
    String unitId = request.getParameter("unitId") == null ? "" : request.getParameter("unitId");
    String businessType =
        request.getParameter("businessType") == null ? "" : request.getParameter("businessType");
    String masterId =
        request.getParameter("masterId") == null ? "" : request.getParameter("masterId");
    String contractId =
        request.getParameter("contractId") == null ? "" : request.getParameter("contractId");
    String monId = request.getParameter("monId") == null ? "" : request.getParameter("monId");

    InputStream templateIn = investmentPlanService.getExcelTemplate(businessType);

    if (templateIn != null) {
      Map<String, String> map1 = new HashMap<String, String>();
      map1.put("sjType", sjType);
      map1.put("unitId", unitId);
      map1.put("businessType", businessType);
      map1.put("masterId", masterId);
      map1.put("contractId", contractId);
      map1.put("monId", monId);
      ExcelExportByTemplate excelExport = new ExcelExportByTemplate(templateIn, map1);
      ByteArrayOutputStream outStream = excelExport.fillDataToExcel();

      response.setContentType("application/octet-stream");
      response.setHeader(
          "Content-Disposition",
          "attachment; filename=计划数据_" + businessType + "_" + unitId + "_" + sjType + ".xls");
      OutputStream out = response.getOutputStream();
      out.write(outStream.toByteArray());

      out.flush();
      out.close();
    } else {
      System.out.println("没有相关的模板信息!");
    }
  }