hi
We render some 100 cols by 17K rows worth of data in a single sheet and per sheet render time is really high. We use 17.12 but I have tried with latest version also - same effect.
We render cell by cell as that helps us have better control on data (if we have to put specific formatting)
Sample code :- (NOT ACTUAL - but does the same)
We have a source custom object “rawData” and a set of workbook styles “exportStyles”
Cells c=wrkSheet.getCells();
for(int i…)
{
for(int j;…)
{
if(rawData.get(i,j).getType().equalsIgnoreCase(“3Decimal”));
{
Double d=Double.parseDouble(rawData.get(i,j).getValue());
c.get(i,j).setValue(d);
Style cellStyle=exportStyles.get(“THREE_DECIMAL_STYLE”);
cellStyle.setCustom(“#,##0.000”);
c.get(i,j).setStyle(cellStyle);
}
else if (rawData.get(i,j).getType().equalsIgnoreCase(“2Decimal”))
{
Double d=Double.parseDouble(rawData.get(i,j).getValue());
c.get(i,j).setValue(d);
Style cellStyle=exportStyles.get(“TWO_DECIMAL_STYLE”);
cellStyle.setCustom(“#,##0.00”);
c.get(i,j).setStyle(cellStyle);
}
else if (rawData.get(i,j).getType().equalsIgnoreCase(“Integer_Typ”))
{
Integer intval=Integer.parseint(rawData.get(i,j).getValue());
c.get(i,j).setValue(intval);
Style cellStyle=exportStyles.get(“TWO_DECIMAL_STYLE”);
cellStyle.setCustom(“#,##0”);
c.get(i,j).setStyle(cellStyle);
}
}
}
Even If I remove the rawData from the picture and try to apply the values right out of DB or a file, the performance remains the same. So, I was sure that my custom object is not causing the issue.
I went through a below post (suggested to me earlier too) to render cells faster - render row by row - import one row as complete array at a time:
I see the performance bump up - my previous render time was 25 mins and was reduced to 2 mins BUT this benchmark is without this custom setting up of styles/custom formats.
So:
a) I was trying to look for a way if I do not have to follow this new approach - as have to make a lot of changes to my code to render the file differently.
Can I allocate a fixed amount of “cell (s)” ahead of time so that
c.get(i.j).setValue or c.get(i,j).setStyle do not take much time.
b) Setting the styling - the only way I see is to have cellRanges and then parse through one at a time and set the Style. IS there a faster way.
Memory is not a concern and does not even go to 20% of capacity also while running.
thanks
Chetan