views:

172

answers:

0

Hi,

Currently I am doing the following in a loop (at least 300 times): - create a HSSFWorkbook from a template file - add some values to specific cells in the workbook - save the workbook as a new excel file

The first line takes about 70% of the time (reading excel file). What I would like to do is to take this out of the loop, and read the file only once. In the loop, I would like to copy or clone the template HSSFWorkbook.

However, I can't find anything about copying/cloning a HSSFWorkbook. Did some of you do this before? Any tips?

@gvkv: I cannot post my complete source code, however, I will post the most relevant parts, although I'm pretty sure it will not have a big added value to this question.

In a loop:

//opening
fileIn = new FileInputStream(fileName);
HSSFWorkbook wb = new HSSFWorkbook(fileIn);
fileIn.close();

//lots of cells being created here...

//saving
fileOut = new FileOutputStream(outputFile);
workbook.write(fileOut);
fileOut.flush();
fileOut.close();