poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raffaele Castagno <raffaele.casta...@gruppotesi.com>
Subject Re: Apache POI formula cell duplication very slow
Date Mon, 27 Feb 2012 19:36:47 GMT
I've made some test, and it seems this is the solution.
I've reverted all my changes, and replaced

// If the row exist in destination, push down all rows by 1 else create a new row
if (newRow != null) {
     worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1);
} else {
     newRow = worksheet.createRow(destinationRowNum);
}

with

if(newRow == null)
{
     newRow = worksheet.createRow(destinationRowNum);
}

and now the generated excel is identical to the one I had before, but is generated in a fraction
of the time.

Thanks everyone.

Raffaele

On 27/02/2012 19:19, Raffaele Castagno wrote:
> Oh my...I think I found it...
>
> Original was:
>
> // If the row exist in destination, push down all rows by 1 else create a new row
> if (newRow != null) {
>     worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1);
> } else {
>     newRow = worksheet.createRow(destinationRowNum);
> }
>
> I've commented all leaving only
>
>     newRow = worksheet.createRow(destinationRowNum);
>
> And now I'm down to 60sec to process all rows!
>
> Probably, there's some dirt in my template which was causing POI to shift everything
at each iteration.
>
> I'll have to double-check my final excel for correctness, but I think I solved it!
>
> Thanks everyone!
>
> Raffaele C.
>
> On 27/02/2012 14:37, Nick Burch wrote:
>> On Mon, 27 Feb 2012, Raffaele Castagno wrote:
>>>> You can estimate parsing time by calling the formula parser explicitly:
>>>>
>>>>          Ptg[] ptgs = HSSFFormulaParser.parse(formula, workbook);
>>>>
>>>> Are you sure it is the bottleneck?
>>>
>>> Tried some variations, been unable to test explicit formula parsing
>>
>> You should try it, the code Yegor posted above is all you need. That will let you
be sure if it's the formula parsing or something else
>>
>> Nick
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Mime
View raw message