https://bz.apache.org/bugzilla/show_bug.cgi?id=69865

            Bug ID: 69865
           Summary: CellUtil.setCellStyleProperties poor performance
           Product: POI
           Version: 5.4.1-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

We observe a deterioration in the performance of
CellUtil.setCellStyleProperties for large workbooks after upgrading POI. This
is a well-known issue.

However, according to our measurements, there is room for improvement. The
method CellUtil.setCellStyleProperties checks whether a style to be used is
already available in the workbook. To do this, it iterates through all existing
styles using workbook.getCellStyleAt(i) and converts them into a map via
getFormatProperties. When a workbook contains many styles and is large in size,
this operation is executed multiple times for the same arguments. Although the
getFormatProperties conversion itself is fast, repeated execution significantly
increases total processing time.

In most cases, the style at position i is unlikely to have changed. Instead of
repeatedly converting the style via getFormatProperties, a cache can be created
to store workbook styles already converted into maps. According to our
measurements, this approach reduces formatting time by almost one third.

Naturally, care must be taken to clear the cache if the underlying styles
change. Indeed, it can happen (e.g., in StylesTable.removeNumberFormat), but
such cases are rare and manageable—especially if the cache is implemented
directly in StylesTable, which is the data source for
CellUtil.getFormatProperties.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to