Bug 45373

Summary: Huge performance problems
Product: POI Reporter: Jens Klinker <jens.klinker>
Component: HSSFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: 3.0-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description Jens Klinker 2008-07-10 05:11:03 UTC
I´m using jxl, jx:if-tags, inside jx:for. This (jx:if) is calling very often the following function and so I have huge performance problems!

Used poi-version:


	public void shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight) {

Ist improvement:

line-number 1199: problem is call of row2Replace.getLastCellNum() on each iteration:

for ( short col = row2Replace.getFirstCellNum(); col <= row2Replace.getLastCellNum(); col++ )

why you don´t use following code instead? I save 30 % time!

short col=row.getFirstCellNum();
short lastCol=row.getLastCellNum();
while (true){
if(col > lastCol){

IInd improvement:

line-number 1228: I removed the following code because I never work with comments, and most other people also. And I save again about 30 %. Perhaps you should make this optional by using boolean parameter?

HSSFComment comment = getCellComment(rowNum, col);
if (comment != null) {
comment.setRow(rowNum + n);

With this 2 changes now I need 20 secs instead of 1 min!
Comment 1 Jens Klinker 2008-07-10 06:52:37 UTC
I´ve changed this:
short lastCol=row.getLastCellNum();

to this:
int lastCol = row.getPhysicalNumberOfCells();

now, I need 2 secs! instead of 1 min!
Comment 2 Nick Burch 2008-07-10 10:52:41 UTC
Your proposed fix using physical number of cells won't work for cases where there are gaps in the row, with not all cells being defined.

I've made some changes to HSSFSheet.shiftRows, committed to svn trunk. These should hopefully speed the method up, whilst ensuring that everything that needs to be moved is. Hopefully this does what you need?