`
nice2230
  • 浏览: 4764 次
  • 性别: Icon_minigender_2
  • 来自: 深圳
社区版块
存档分类
最新评论

ExportExcel

    博客分类:
  • java
 
阅读更多

一、java 导出操作。

1.)ExportExcel.java类
public class ExportExcel {
        @SuppressWarnings("all")
	public static <T> void export(String templateName, List list,Properties config) throws IOException, InvalidFormatException {
		ExcelUtils excelUtils = new ExcelUtils();
		// String actionName = getActionSimpleName(action.getClass());
		ExcelConfig excelConfig = new ExcelConfig(config);
		ExcelConvert convert = new ExcelConvert();
		convert.setConfig(excelConfig);
		excelUtils.setExcelConfig(excelConfig);
		List table = convert.converTable(list);
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		// excelTemplate = config.getProperty("export.template", "config/" +
		// actionName + ".xls");
		// InputStream inputstream =
		// action.getClass().getResourceAsStream(excelTemplate);
		InputStream inputstream = new ExportExcel().getClass().getResourceAsStream(config.getProperty("export.template"));
		excelUtils.writeToExcel(table, inputstream,
		excelConfig.getExpBeginRow(), excelConfig.getExpBeginCell(), out);
		inputstream.close();
		String fileName = config.getProperty("export.filename", templateName + ".xls");
		Servlets.getResponse().setHeader("Content-Disposition","attachment; filename="+ new String(fileName.getBytes(), "ISO8859-1"));
		Servlets.getResponse().setContentType("application/vnd.ms-excel");
		Servlets.getResponse().setContentLength(out.size());
		out.writeTo(Servlets.getResponse().getOutputStream());
	}
}

    

2.)controller类
@Controller
@RequestMapping("/political/ledgerTransfer.do")
public class LedgerTransferController {    
       @SuppressWarnings("unchecked")
	@ResponseBody
	@RequestMapping(params="exportData")
	public void exportData(Transferwithin ledgerTransfer,HttpServletRequest request,HttpServletResponse response) throws RunanException{
		try {
			Properties temp_properties = new Properties();
			InputStream in = getClass().getResourceAsStream("/config/excel/properties/political/ledgerTransfer_imp_excel.properties");
			try {
				temp_properties.load(in);
			} catch (IOException e) {
				throw new RunanException();
			} finally {
				in.close();
			}
			List<Mutualsupervisionteam> list = new ArrayList<Mutualsupervisionteam>();
			ExportExcel.export("mutualsupervisionteam",list, temp_properties);
		} catch (Exception e) {
			throw new RunanException();
		}
	}
}

 

3.)jsp
//下载模板
$("#downloadExcelModel").bind("click",function(){
	window.location.href ="${base}/political/mutualsupervisionteam.do?excelModel";
});

 

 

 

0
1
分享到:
评论

相关推荐

    js-exportExcel.rar

    "js-exportExcel.rar" 提供的资源就是利用JavaScript来实现表格数据导出为Excel文件的功能,这对于数据展示和分析非常实用。在描述中提到的“100%好用”意味着这个解决方案经过了充分的测试,能够稳定运行。 “js ...

    exportexcel

    标题“exportexcel”和描述“导出excel”都指向了一个常见的IT操作,即从系统或应用中将数据导出到Microsoft Excel格式的文件。在许多业务环境中,Excel因其强大的数据分析和处理能力而被广泛使用。这里,我们主要...

    ExportExcel.dll源碼

    《ExportExcel.dll源码解析与应用实践》 在IT行业中,数据导出是常见的需求,尤其是在Web应用程序和桌面应用程序(WinForm)中。"ExportExcel.dll"是一个专门为ASP.NET平台设计的组件,它使得开发者能够方便快捷地...

    exportExcel.zip

    首先,我们来看“exportExcel.zip”这个压缩包,它包含了实现Vue前端导出Excel所需的文件。从描述中我们可以推测,这个压缩包可能包含了一个或多个示例代码文件,用于演示如何在Vue应用中执行Excel导出。具体的实现...

    使用注解SpringMVC从页面导出Excel和word文档的使用的jar包——使用ExportExcel工具类.rar

    本教程将详细介绍如何利用注解和ExportExcel工具类来实现这一目标。 首先,我们需要了解SpringMVC中的注解。在SpringMVC中,注解主要用于简化配置,如@Controller、@RequestMapping、@GetMapping、@PostMapping等,...

    exportExcel.js-Blob.js.zip

    本主题关注的是使用JavaScript实现Excel文件的导出功能,具体涉及两个核心文件:`exportExcel.js` 和 `Blob.js`。这两个文件的结合使用,允许开发者在不依赖服务器端支持的情况下,直接在浏览器环境中生成并下载...

    ExportExcel16_Excelvc_widelyghp_

    针对“ExportExcel16_Excelvc_widelyghp_”这个主题,我们可以深入探讨一下如何在Office 2016版本中利用Visual C++(简称VC)进行Excel数据的读写操作。 首先,我们要理解Excel数据读写的原理。在Office 2016中,...

    ExportExcel 【JQuery+jquery.table2excel.js】修正

    "ExportExcel 【JQuery+jquery.table2excel.js】修正"是一个关于使用JQuery库和一个特定的插件——jquery.table2excel.js来实现表格数据导出为Excel文件的改进项目。在原始版本的jquery.table2excel.js中存在一些...

    ExportExcel.zip

    当我们需要将大量数据从数据库或其他程序导出到Excel时,"ExportExcel"这个概念就显得尤为重要。本篇文章将深入探讨如何实现数据的导出以及与Excel相关的技术。 1. **数据导出的基本原理**: 数据导出是将存储在...

    ExportExcel.rar

    "ExportExcel.rar"压缩包提供的资源可能包含了一个实现此功能的示例代码或者库。下面我们将深入探讨如何在Asp.Net Core中实现列表数据的Excel导出。 首先,我们需要理解Asp.Net Core是一个跨平台的开源Web框架,它...

    ExportExcel.cs

    c# NOPI导出excel 多表头,多sheet页。 实现DataSet导出不同的sheet页,数据库列名与中文名列名转换,多表头,实现合并单元格,两行表头设计。

    ExportExcel.java

    封装了一个导出2003版本Excel的方法的工具类,只需传入对应的参数即可,(2007版本只需修改对应的接口即可)

    WebAPI.ExportExcel:用于导出 Excel 的 Web API

    WebAPI.ExportExcel 是一个专为实现 Excel 导出功能的 Web API 解决方案。这个 API 主要被设计用于 web 应用程序,允许用户通过简单的 HTTP 请求从服务器获取并下载 Excel 文件。在 JavaScript 开发环境中,这样的...

    exportExcel的js

    导出Excel的js,用于攒积分换取

    exportExcel_javascript

    exportExcel_javascript 发布日期:Excel Excel파일로떨궈주세요。 插图:테이블은이미지로넣되,테이여주세요이여주세요보여주세요 구현:달성하기위한기본스본스트。 직로직 querySelectorAll로차트가그려진...

Global site tag (gtag.js) - Google Analytics