如何让jxl (jexcelapi) 支持更多的数据

阅读更多
jxl (jexcelapi) 一直是我比较喜欢的 java版excel读写组件.
主页
http://www.andykhan.com/jexcelapi/index.html

网上关于 jxl使用的文章 太多太多  我就不再重复jxl的用法了.

决定写这篇文章 有点偶然:
刚刚 我用"setUseTemporaryFileDuringWrite" 做关键字,去google里面搜索,
想看看有没有这个的更多技巧(实在没有功夫去看jxl的源码)

google之后, 居然没有一条 中文的 结果.


这也许说明国内还没有一篇文章 来介绍 jxl 的setUseTemporaryFileDuringWrite 相关内容吧.

那我就来啰嗦两句吧, 这个也不是啥高深技术, 算作一个小知识点吧.

大家可以参见 jxl 的 changehistory : ( 写本文时最新版本是 2.6.9 for jdk 1.4)
引用

Version 2.6.5 (Sept 2007)

Fixed a bug to allow more than one conditional format per cell
Adjusted the cells referenced by named blocks when inserting and deleting rows
Added a synchronised block when initialising the workbook to prevent race conditions in multi-threaded environments
Migrated formula parsing to the JFlex (rather than JLex) for performance reasons. This is a GPL product - see notice on main page of the website
When writing out a file, it is now possible to write out a temporary file, rather than generate the whole thing in memory. This feature is accessible via the WorkboodSettings bean (useTemporaryFileDuringWrite) or the system property jxl.usetemporaryfileduringwrite
Set the atan function to have two arguments
Supported the copying of WritableSheets within a Workbook, as well as read only ones (this was throwing a ClassCastException)
Lists in drop downs can only be a maximum of 256 characters. If this length is exceeded truncated the string and presented a warning
Added a non-documented workaround in order to resolve a bug in some version of the JVM not recognising the character encoding "UnicodeLittle"



看 红色字部分. 这个特性真的很不错, 但是jxl官方没有提供示例,
大家看一下 我下面的这个代码片段吧
(什么是Workbook 以及 如何创建一个excel文件 我就不说了 )


WorkbookSettings settings=new WorkbookSettings ();

settings.setUseTemporaryFileDuringWrite(true);

WritableWorkbook workbook = Workbook.createWorkbook(outputStream, settings);




很简单.
当按示例中的写法 开启 UseTemporaryFileDuringWrite 后,
jxl在生成excel文件时 所支持的单个文件记录数 确实提高很多.

我这边的测试结果是 开启功能比不开启 多支持了 10000 余行.
(当然 这和列数 以及每列的内容也有关. 而且开启后速度略慢 )


===========================

简单的小知识点 没啥好说的了 . 希望对大家有所帮助.

over

你可能感兴趣的:(Excel,Google,Bean,JVM,performance)