Excel花费太多时间编写 [英] Excel Taking Too much time to write

查看:94
本文介绍了Excel花费太多时间编写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在编写一个程序,以从一个文本文件(test.txt)写入Excel文件(testExcel.xls).在这里,我正在使用2万条数据.需要太多时间(8小时).我需要一个解决方案.我正在使用JExcel.

程序流程:


步骤1:从test.txt中读取数据

Hi all,

I am writing a program to write into Excel file(testExcel.xls) from one text file(test.txt). Here I am using 20 thousand of data. it take too much time(8 hrs). i need a solution. I am using JExcel.

Flow of programme:


Step1: read the data from test.txt

while(){

    Step2: take one line of data
    Step3: Open the testExcel.xls
    Step4: Write
    Step5: Close
}


在此逻辑之前,我使用了一种逻辑,在Step2之后,


Before this logic I used one logic that After Step2,

Step3: Store data
Step4: Open Xls file 
while(){
   Step5: Write
}
Step5: Close the file



但是我超时了
帮我....



But i get time out Exception
help me ....

推荐答案

我不知道您的文本文件的格式.但是将其转换为csv(如果尚未采用该格式)并将其作为excel文件打开该怎么办?

另一种方法是首先创建一个包含所有数据的数组,并将其设置为范围(setValue2).这也是读取许多值的最佳方法.如果要比一次读取一个单元格更快地读取整个值,请使用整个工作表的getValues 并对该数组进行处理.这是由于对象编组占用了大部分时间.因此,通过执行一次调用而不是多次(慢速)调用来减少这种情况.

祝你好运!
I don''t know the format of your text file. But what about converting it to csv (if not already in that format) and open that as excel file?

Another way is to first creae an array with all the data and set this to a range (setValue2). That is also the best for reading a lot of values. Using getValues of the complete sheet and work on that array if much faster than reading some values one cell at a time. This is due to object marshalling that takes up most of the time. So reduce that by doing a single call instead of multiple (slow) ones.

Good luck!


这篇关于Excel花费太多时间编写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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