Discussion:
Reading macro using apache poi is taking too long
vijay
2013-05-31 18:32:32 UTC
Permalink
I'm big big fan of apache Poi, I used it for reading/writing excel before.
Now I want to use apache poi for reading a macro for my project.
Agreed my macro has 10 sheets but creating workbook oibject is taking too
long.


FileInputStream file = new FileInputStream(new File("C:\\test.xlsm"));

XSSFWorkbook wb = new XSSFWorkbook(file);


The step of creating workbook object is taking atleast 2 mins. Can anyone
please explain why and what can be done to improve.



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Reading-macro-using-apache-poi-is-taking-too-long-tp5712869.html
Sent from the POI - User mailing list archive at Nabble.com.
Dominik Stadler
2013-06-01 05:22:52 UTC
Permalink
Hi,

It is impossible to state anything without a look at how you create the
file or how the file looks like. Can you provide a sample file which allows
others to reproduce the behaviour?

Thanks... Dominik.
Post by vijay
I'm big big fan of apache Poi, I used it for reading/writing excel before.
Now I want to use apache poi for reading a macro for my project.
Agreed my macro has 10 sheets but creating workbook oibject is taking too
long.
FileInputStream file = new FileInputStream(new File("C:\\test.xlsm"));
XSSFWorkbook wb = new XSSFWorkbook(file);
The step of creating workbook object is taking atleast 2 mins. Can anyone
please explain why and what can be done to improve.
--
http://apache-poi.1045710.n5.nabble.com/Reading-macro-using-apache-poi-is-taking-too-long-tp5712869.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
Nick Burch
2013-06-01 10:41:32 UTC
Permalink
Post by vijay
I'm big big fan of apache Poi, I used it for reading/writing excel
before. Now I want to use apache poi for reading a macro for my project.
Agreed my macro has 10 sheets but creating workbook oibject is taking
too long.
FileInputStream file = new FileInputStream(new File("C:\\test.xlsm"));
XSSFWorkbook wb = new XSSFWorkbook(file);
If you have a file, don't go via an inputstream! It increases the amount
of memory needed, and slows things down. See
http://poi.apache.org/spreadsheet/quick-guide.html#FileInputStream

Other than that, when you're using a file, if it's still slow you'll need
to use a profiler to check what code is the problem.

Nick

Loading...