在Apache中POI AutoSizeColumn性能的影响 [英] AutoSizeColumn performance effect in Apache POI

查看:1578
本文介绍了在Apache中POI AutoSizeColumn性能的影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Apache POI创造的一些记录Excel表。一个这样的记录有16K行。我使用的是循环记录写入Excel工作表,并在我使用的每一次迭代 autoSizeColumn()来汽车大小的列。这样,我无法下载/因为它正在采取永远完成写入过程写入Excel文件。虽然我在浏览SO,我碰到凡用户曾提到,使用的autoSizeColumn()阻碍性能的答案。因此,为了测试,我删除了 autoSizeColumn()和检查,使我惊奇的它工作得很好。

I am using Apache POI to create Excel sheets of some records. One such record has 16k rows. I am using a for loop to write records into the excel sheet and in each iteration I am using autoSizeColumn() to auto size the columns. This way I am not able to download/write to the excel file as it is taking forever to complete the writing process. While I was browsing SO, I came across an answer where an user had mentioned that the use of autoSizeColumn() hinders the performance. So, to test that, I removed the autoSizeColumn() and checked, to my wonder it worked fine.

我的问题 - 是不是因为我迭代16K倍自动调整大小的列,那我不能够完成的写作过程?还是 autoSizeColumn()有任何性能影响?如果我这样有什么其他可以使用,为了写16K(大量的)记录,以及有列汽车大小,以它们的内容。

My question - Is it because I am iterating 16k times to auto size the columns, that I am not able complete the writing process? Or does autoSizeColumn() have any performance effects? If so what alternative can I use, in order to write 16k(large number of) records as well as have the columns auto sized to their contents.

任何形式的帮助是AP preciated。先谢谢了。

Any kind of help is appreciated. Thanks in advance.

推荐答案

autoSizeColumn()方法确实需要大量的时间,如果有很多调整列。
一种解决这一问题的是做要求所需的柱的 autoSizeColumn()方法仅已创建的所有行之后,而不是在每次迭代。
此方法的javadoc中提及以下内容:

The autoSizeColumn() method does take a lot of time if there are a lot of columns to resize. One solution to this problem is to do call the autoSizeColumn() method for the required column only after all the rows have been created, not in each iteration. The javadoc for this method mentions the following:

:此过程可以在大张的相对较慢的,所以这应该通常只进行一次每列被调用,在您的处理结束。

这篇关于在Apache中POI AutoSizeColumn性能的影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆