导入导出Excel的方法总结:
导入导出Excel表格的包有poi.jar包 和jxl.jar包,两种包都可以实现Excel表格进行操作;
(一) poi.jar包介绍
poi介绍:Jakarta POI - Java API To Access Microsoft Format Files
有一下几个包:
POIFS: for OLE 2 Documents ,POIFS is the oldest and most stable part of the project. It is our port of the OLE
2 Compound Document Format to pure Java.
HSSF :for Excel Documents,HSSF is our port of the Microsoft Excel 97(-2002) file format (BIFF8) to pure Java.
HWPF :for Word Documents ,HWPF is our port of the Microsoft Word 97 file format to pure Java.
HPSF :for Document Properties,HPSF is our port of the OLE 2 property set format to pure Java
下面简单介绍一下HSSF
还有一种就是使用过滤器和 Extreme Table自定义空间结合使用 ,首先在web.xml中配置ExportFilter过滤器 ,然后在 <ec:table/>中添加<ec:exportXls/> 标签
jsp: <ec:exportXls fileName="userExcel.xls" tooltip="导出为电子表格文件" text="XLS"/>
(二)jxl包介绍:
jExcelAPI是一个韩国程序员的作品,虽然没有POI那样血统高贵,但是在笔者 的使用过程中, 感觉简单方便,对中文支持非常好,功能也比较强大。最关键的是这套API是纯Java的, 并不依赖 Windows系统,即使运行在Linux下,它同样能够正确的处理Excel文件。 另外需要说明的是,这套API对图形和图表的支持很有限,而且仅仅识别PNG格式。下面是相关代码实现:
(三)使用页面Response.ContentType设置网址返回的内容类型
application/vnd.ms-excel是Excel表格 ,类似于text/html是HTML页面;
4590

被折叠的 条评论
为什么被折叠?



