美文网首页
导出文档的压缩包(自用)

导出文档的压缩包(自用)

作者: 三没产品 | 来源:发表于2019-12-11 17:06 被阅读0次
      res = response.getOutputStream();
      // 清空输出流
      response.reset();
      SimpleDateFormat sFormat = new SimpleDateFormat("yyyyMMddhhmmss");
      String realFileName = "template" + sFormat.format(new Date());
      // 设定输出文件头
      response.setHeader("Content-disposition ",
          "attachment; filename=" + URLEncoder.encode(realFileName, "utf-8") + ".zip ");
      response.setContentType("application/zip");
    //             ZipOutputStream zos = new ZipOutputStream(res, StandardCharsets.UTF_8);
      ZipOutputStream zos = new ZipOutputStream(res);
    
      for (List<PracticeApplyTableData> dates : map.values()) {
          ByteArrayOutputStream output = new ByteArrayOutputStream();
          exportApplyTable(yearM, dates, output);
          byte[] buffer = output.toByteArray();
          ZipEntry entry = new ZipEntry("test" + dates.get(0).getTeachName() + ".doc");
          zos.putNextEntry(entry);
          //                 zos.setEncoding("UTF-8");
          zos.write(buffer);
      }
      zos.flush();
      zos.close();
    

    相关文章

      网友评论

          本文标题:导出文档的压缩包(自用)

          本文链接:https://www.haomeiwen.com/subject/faqagctx.html