1

I made an app that takes aproximately 5 secs to give the results I want. Using VisualVm i just noticed that 4 seconds are taken by the following code, for 69 files in total:

FileInputStream matriculeFile = null; 
XSSFWorkbook matriculeWorkbook = null;
XSSFSheet matriculeSheet = null;

try {

    matriculeFile = new FileInputStream(new File(
    sheetsDirectory + "\\" + matricule + ".xlsm")); // Open matricule file

    matriculeWorkbook = new XSSFWorkbook(matriculeFile);
    matriculeSheet = matriculeWorkbook.getSheetAt(0);
}catch(Exception e){e.getStackTrace();}

My question is. Is there any other way to obtain the same results, saving time, such as using other methods?

Thanks in advance

Mohammadreza Khatami
  • 1,444
  • 2
  • 13
  • 27
  • 1
    Is it a very big Excel file? Is it in a place where it takes time to load it (for example on a slow network drive)? – Jesper Aug 10 '16 at 10:30
  • The posted code doesn't show any "processing" of the workbook, maybe you should post that as well –  Aug 10 '16 at 10:31
  • Hi Jesper. It's not. Each file is 45*40 cells with a lot of black_cells. No, saved in my (C:) OSDISK. Thanks for replying – Fábio Rodrigues Aug 10 '16 at 10:35
  • RC, thanks for replying. I'm new and I'm not sure if it is needed, but using VisualVm i noticed that the method XSSFWorkbook() that calls the method load(XSSFFactory.getInstance() from XSSFWorkbook class is the one that takes too much time. I am looking for an equivalent method that may provide the same result. – Fábio Rodrigues Aug 10 '16 at 10:42
  • You could try giving more heap space with `java -Xmx=...`. Try `new BufferedInputStream(...)` first. – Joop Eggen Aug 10 '16 at 11:37
  • Some reading: http://stackoverflow.com/questions/11154678/xssfworkbook-takes-a-lot-of-time-to-load –  Aug 10 '16 at 12:21

0 Answers0