有时,客户需要一个标准的模板来填东西,然后在导入

这时可以弄好excel模板,供导出

/**

* 导出excel模板文件

* @param request

* @param response

* @return

* @throws Exception

*/

@RequestMapping("downLoadExcelModel")

@Action(description="导出子表Excel模板文件")

public void exportExcelMode(HttpServletRequest request,

HttpServletResponse response) throws Exception{

String dirPath = FileUtil.getRootPath() + File.separator+"commons" +File.separator+"template"+File.separator+"exportMode"+File.separator;

String fileName="负荷预测日报表模板.xls";

///oms/web/commons/exportMode/负荷预测日报表模板.xls

FileInputStream inStream = new FileInputStream(new File(dirPath+fileName));

byte[] buf = new byte[4096];

int readLength;

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

response.setHeader("Content-Type","application/vnd.ms-excel");

response.setHeader( "Content-Disposition", "attachment;filename=" + new String( fileName.getBytes("GB2312"), "8859_1" ));

response.addHeader("Pargam", "no-cache");

response.addHeader("Cache-Control", "no-cache");

OutputStream out = response.getOutputStream();

while (((readLength = inStream.read(buf)) != -1)) {

out.write(buf, 0, readLength);

}

inStream.close();

out.flush();

out.close();

}

导出Excel(导出一个模版)的更多相关文章

  1. yii2 数据导出 excel导出以及导出数据时列超过26列时解决办法

    作者:白狼 出处:http://www.manks.top/article/yii2_excel_extension​ 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给 ...

  2. WPF 导出Excel 导出图片

    /// <summary> /// 导出Excel /// </summary> private void ExportExcel(DataTable ExcelDt) { / ...

  3. response导出Excel(一个新手的记录,可以时常查看,以免自己忘记)

    HttpResponse response = HttpContext.Current.Response;  response.ContentEncoding = System.Text.Encodi ...

  4. npoi导出excel 导出List<T>

    using System.Collections.Generic; using NPOI.HSSF.UserModel; using NPOI.SS.UserModel; using NPOI.XSS ...

  5. jxls使用模版导出Excel

    /**     * 使用模版导出Excel     */    @SuppressWarnings({ "unchecked", "deprecation" } ...

  6. NPOI复制模板导出Excel

    本人菜鸟实习生一枚,公司给我安排了一个excel导出功能.要求如下:1.导出excel文件有样式要求:2.导出excel包含一个或多个工作表:3.功能做活(我的理解就是excel样式以后可能会变方便维 ...

  7. AX导出excel设置格式

    今天在AX2009里面写一个导出EXCEL,没有模版,这是第一次碰到,之后写完之后发现导出的数据格式不对. 到处取经之后得到一下结果: 定义一个 Com   range; SysExcelCells  ...

  8. C#导出Excel那些事

    Excel导出 Excel导出的意义 因为在项目中有些报表数据客户需要导出功能,那么导出为Excel就十分有必要了,可是有些客户的机器上并没有安装Excel或者安装的版本参差不一.那么我们在这样的情况 ...

  9. 如何使用JavaScript实现纯前端读取和导出excel文件

    js-xlsx 介绍 由SheetJS出品的js-xlsx是一款非常方便的只需要纯JS即可读取和导出excel的工具库,功能强大,支持格式众多,支持xls.xlsx.ods(一种OpenOffice专 ...

  10. springboot通过poi导出excel

    Maven引入依赖 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi< ...

随机推荐

  1. java.util.Queue(队列)的简单使用

    import java.util.LinkedList; import java.util.Queue; import org.junit.Before; import org.junit.Test; ...

  2. Javascript--数组转换成字符串

    定义和用法 toString() 方法可把数组转换为字符串,并返回结果. 语法 arrayObject.toString() 返回值 arrayObject 的字符串表示.返回值与没有参数的 join ...

  3. Android打印当前所有线程及对应栈信息

    Map<Thread, StackTraceElement[]> threadMap = Thread.getAllStackTraces(); Log.e("albertThr ...

  4. linux命令学习(3):ls命令

    ls命令是linux下最常用的命令.ls命令就是list的缩写,缺省下ls用来打印出当前目录的清单.如果ls指定其他目录,那么就会显示指定 目录里的文件及文件夹清单. 通过ls 命令不仅可以查看lin ...

  5. 【react】---手动封装一个简易版的redux---【巷子】

    export let createStore = (reducer)=>{ //定义默认的state let state = {}; //定义默认的action let actionTypes ...

  6. DB2 rollforward 命令使用详解

    DB2 rollforward 命令使用详解 原文:https://www.ibm.com/developerworks/cn/data/library/techarticles/dm-1003wuc ...

  7. VS2015 工具箱 保存位置

    我的文档\Visual Studio 2015\Settings\CurrentSettings.vssettings Environment_Toolbox 节点 <Category name ...

  8. 引用:WebAPI中的定时处理-使用Quartz.Net

    引用: https://blog.csdn.net/lordwish/article/details/78926252 主要是给自己做个记录,不用到处找,这篇文章写的很全,推荐 文中:在项目的Glob ...

  9. 洛谷P1147 连续自然数和【二分】

    题目:https://www.luogu.org/problemnew/show/P1147 题意: 给定一个数m,问有多少个数对$(i,j)$,使得$i$到$j$区间的所有整数之和为m.输出所有的解 ...

  10. 电子产品使用感受之--Mac Mini 买了之后有什么用?-- 开发啊!

    2019.01.29 更新 Mac Mini 2018这么强劲的性能,不用来做点儿什么真是可惜了. 如果只是用来看看Youtube视频,打开网页看看twitter什么的,那可真是巨大的浪费了. 因为这 ...