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

--- Comment #3 from [email protected] ---
I prefer not to extend the signature of the existing setCellStyleProperties
methods: once an API is extended, it cannot easily be reduced again. Moreover,
most applications will continue using the old API and therefore will not
benefit from the performance improvements introduced after the POI upgrade.

IMHO, it is the storage in workbook.getCellStyleAt where the true workbook
style data reside and they should be kept there in the EnumMap-form, too, to
accelerate styling operations. 

Specifically, for HSSF these data reside in
org.apache.poi.hssf.model.InternalWorkbook, and for XSSF/SXSSF they reside in
org.apache.poi.xssf.model.StylesTable.

Since we are now dealing with internal structures, the workbook method should
probably be slightly more abstract—something like:

Map<CellPropertyType, Object> getCellStyleAt(
    int idx,
    Function<CellStyle, Map<CellPropertyType, Object>> enumMapBuilder
)


If the EnumMap is already available in the cache, it would be returned; if not,
the enumMapBuilder would be used to create an EnumMap, which would then be
cached and returned. Both InternalWorkbook and StylesTable have full control
over their elements, and methods like StylesTable.removeNumberFormat can
partially clear the cache as a side effect. A similar method exists in
InternalWorkbook—removeExFormatRecord—although it is so dangerous that it is
almost unusable.

Of course, this approach is not without risk (nor can it ever be). Both
org.apache.poi.hssf.Record and
org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTXfImpl expose public
methods; if these objects are retrieved from their respective stores and
modified directly, the cache would remain unaware of the changes. This would be
closer to hacking than programming.

On the other hand, one can never be certain what the application using the
library is actually doing (or why). Therefore, the caching feature should be
made configurable, allowing a legacy mode with no caching to be enabled when
truly necessary.

-- 
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