如何加速的excel读/写 [英] How to speed up excel reading/writing

查看:257
本文介绍了如何加速的excel读/写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Apache POI来读取/写入到Excel文件为我公司作为实习生在这里。我的程序经过Excel文件这是一个大广场与顶级行计算机名称和左栏用户名。 240台电脑和342用户。板材[电脑] [用户]在所有的空格0和程序调用PSLoggedon为每台计算机和采用用户名(S)当前登录,并增加他们的0,一个月后,它运行后,它显示谁在登陆最让每一台计算机。到目前为止,它运行在,因为我用一个插座实际调用PSLoggedon前检查socket.connect约25分钟。

I am using Apache POI to read/write to an excel file for my company as an intern here. My program goes through the excel file which is a big square with top rows computer names and left column user names. 240 computers and 342 users. the sheet[computer][user] is 0 in all spaces and the program calls PSLoggedon for each computer and takes the username(s) currently logged on and increments their 0 so after running it after a month, it shows who is logged in the most to each computer. So far it runs in about 25 minutes since I used a socket to check socket.connect before actually calling PSLoggedon.

不读或写在所有的Excel文件时,只调用所有PSLoggedon调用每台计算机上,大约需要9分钟。因此,阅读和写作显然需要10-15分钟。关键是,我在电脑上调用PSLoggedon,然后打开Excel的找到[电脑]的[X] [Y]现货[用户],然后写入到它的+ = 1,那么关闭它。因此,它之所以长期服用此我猜想是因为它打开和关闭文件这么多?我可能是完全错误的。但我不能想办法让这个速度通过打开和读/写一次全部,只有打开和关闭文件一次。任何想法?

Without reading or writing at all to the excel file, just calling all the PSLoggedon calls to each computer, takes about 9 minutes. So, the reading and writing apparently takes 10-15 minutes. The thing is, I am calling PSLoggedon on the computer, then opening the excel to find the [x][y] spot of the [computer][user] and then writing to it a +=1 then closing it. So the reason it is taking this long I suppose is because it opens and closes the file so much? I could be completely wrong. But I can't think of a way to make this faster by opening and reading/writing all at once and only opening and closing the file once. Any ideas?

推荐答案

通常Apache的POI是非常快的,如果你正在运行到一些问题,那么您可能需要检查以下几点:

Normally Apache-POI is very fast, if you are running into some issue then you might need to check below points:


  1. POI的记录可能是,你需要关闭它们:
    您可以添加这些-D之一,您的JVM设置要做到这一点:

  1. POI's logging might be on, you need to turn them off: You can add one of these –D to your JVM settings to do this:

-Dorg.apache.poi.util.POILogger = org.apache.poi.util.NullLogger

您可以您的VM堆被设置为低价值,设法增加。

You may be setting your VM heap to low value, try to increase.

preFER XLS超过XLSX。

Prefer XLS over XLSX.

这篇关于如何加速的excel读/写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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