zoukankan      html  css  js  c++  java
  • java 下载excel模板

    1.我们把需要下载的的excel 模板放在resource下面,模板要什么样子自己修改excel就好

    1.接下来我们读取需要下载的excel模板就好

    String fileName="test";
    ClassPathResource classPathResource = new ClassPathResource("template/eventAndProperty.xlsx");

    // 判断下载哪个excel

    // 初始化流
    InputStream inputStream = null;
    OutputStream outputStream = null;
    try {
    inputStream = classPathResource.getInputStream();
    response.setContentType("application/x-msdownload");
    outputStream = response.getOutputStream();
    response.addHeader("Content-Disposition", "attachment; filename=" + new String(fileName.getBytes(),"iso-8859-1"));
    // 执行流操作
    IoUtils.copy(inputStream,outputStream);
    } catch (IOException e) {
    log.error(e.getMessage());
    }finally {
    // 关流
    IOUtils.closeQuietly(inputStream);
    IOUtils.closeQuietly(outputStream);
    }
  • 相关阅读:
    poj2240
    poj1135
    poj1062
    poj3278
    2218 补丁vs错误
    必做: 1041、1024、1077、2218、1183(较难)
    poj2828
    poj3253
    洛谷P1122 最大子树和
    1074 食物链
  • 原文地址:https://www.cnblogs.com/bt2882/p/13176665.html
Copyright © 2011-2022 走看看