poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Woolsey <greg.wool...@gmail.com>
Subject Re: Loading/closing an excel took too much time
Date Tue, 06 Feb 2018 02:44:05 GMT
XSSF files are zip files containing many XML files.  Unzipping and parsing
these files is where the time is spent.  The specifics depend on the
structure of the workbook, but past history makes it pretty certain the
time is in the XMLBeans library. Also, if you don't have enough RAM
allocated to the Java heap, it may be spending time doing garbage
collection, but with those times, I'd say your files are opening pretty
fast for POI XSSF, and as such are probably small.  The constructor opens
the zip file and parses most of the XML content up front.  As was
previously suggested, the streaming parser may be a better fit for your
needs, as it doesn't need to build as many Java objects up front.

There are many tutorials and examples online for using free and commercial
profilers for Java - web search is your best option there, the right one
for you will depend on your tool stack, OS, and JVM vendor and version, as
well as what exactly you want to track/trace/measure.

On Mon, Feb 5, 2018 at 5:05 PM Chen Young <niaomingjian@outlook.com> wrote:

> Hi,
>
> Thank you for your advice.
>
> I only know that time is spent on workbook = new
> XSSFWorkbook(file);/workbook.close() these two statements.
> How can I use a profiler  to detect where the time is spent more in depth?
>
> Young.
> ________________________________
> 发件人: Dominik Stadler <dominik.stadler@gmx.at>
> 发送时间: 2018年2月5日 22:09
> 收件人: POI Users List
> 主题: Re: Loading/closing an excel took too much time
>
> Hi,
>
> You can take a look at a streaming interface, see e.g.
> https://poi.apache.org/spreadsheet/how-to.html#xssf_sax_api, however I
> cannot guarantee that it will be much faster than the normal open.
>
> Otherwise your best bet is to use a profiler to see where the time is spent
> to see if anything can be improved there.
>
> Dominik.
>
> On Mon, Feb 5, 2018 at 11:05 AM, Chen Young <chin.youyou@outlook.com>
> wrote:
>
> > I'm using the following code to load and close an existing excel.
> >
> > workbook = new XSSFWorkbook(file);
> > workbook.close()
> >
> > Creating XSSFWorkbook took almost 200ms and closing it took almost 100ms.
> >
> > In this excel, there're some formula cells which refer to other excels.
> Is
> > this the reason for slowing?
> > I have more than 3000 files to deal with. So it's too slow for me.
> > Though multiple-thread doubles the speed, I still want to improve more.
> >
> > I just want to read contents from these files and won't make any changes
> > to them.
> > Is there a workround to improve loading/closing speed?
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message