poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 54593] New: Poor performance when adding borders
Date Thu, 21 Feb 2013 10:18:52 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=54593

            Bug ID: 54593
           Summary: Poor performance when adding borders
           Product: POI
           Version: 3.9
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: nikola.stohanzl@ness.com
    Classification: Unclassified

Created attachment 29974
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29974&action=edit
generated XSSF workbooks with and witout bordering

Hi, 

i just started with Apache POI and created a simple test XSSF workbook (see
attached files, sheet is locked, password is "kuku"). I noticed a big gap in
elapsed times after adding borders. Small benchmark (average of 10 consecutive
runs) on my i5@2,5GHz notebook (Oracle JDK 1.7, JVM setting -Xmx256M) shows

XSSF no borders: 700ms
XSSF borders: 2500ms
HSSF borders: 290ms

I use RegionUtil for bordering (as is suggested in the quick guide) and my
bordering helper method looks like

private static void thinBorder(Workbook wb, Sheet sh, CellRangeAddress rng) {
    RegionUtil.setBorderBottom(CellStyle.BORDER_THIN, rng, sh, wb);
    RegionUtil.setBorderLeft(CellStyle.BORDER_THIN, rng, sh, wb);
    RegionUtil.setBorderRight(CellStyle.BORDER_THIN, rng, sh, wb);
    RegionUtil.setBorderTop(CellStyle.BORDER_THIN, rng, sh, wb);        
} 

and i use that approach for bordering single cells as well. After a small
debugging, i found that underlaying calls to CellUtil method

private static void setFormatProperties(CellStyle style, Workbook workbook,
Map<String, Object> properties)

take 30-70ms each. Combined with a creation of different styles during the
bordering, that might be the cause of my problem. Without borders, there are 9
different styles (based on Workbook.getNumCellStyles()), with borders, there
are 66 styles.

Perhaps my bordering strategy can be optimised, but creation of approx. 25
styles per second (if i understand the code logic well) seems like poor
performance and could be a stopper for big workbooks with formatting. I
understand that the HSSF implementation migh be more effective avoiding XML,
but the difference simply seems too big.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


Mime
View raw message