Class FormatTrackingHSSFListener
java.lang.Object
org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener
- All Implemented Interfaces:
HSSFListener
A proxy HSSFListener that keeps track of the document formatting records, and
provides an easy way to look up the format strings used by cells from their
ids.
-
Constructor Summary
ConstructorsConstructorDescriptionFormatTrackingHSSFListener
(HSSFListener childListener) Creates a format tracking wrapper around the given listener, using thedefault locale
for the formats.FormatTrackingHSSFListener
(HSSFListener childListener, Locale locale) Creates a format tracking wrapper around the given listener, using the given locale for the formats. -
Method Summary
Modifier and TypeMethodDescriptionFormats the given numeric of date cells contents as a String, in as close as we can to the way that Excel would do so.int
Returns the index of the format string, used by your cell, or -1 if none foundgetFormatString
(int formatIndex) Returns the format string, eg $##.##, for the given number format index.Returns the format string, eg $##.##, used by your cellprotected int
protected int
void
processRecord
(Record record) Process this record ourselves, and then pass it on to our child listenervoid
processRecordInternally
(Record record) Process the record ourselves, but do not pass it on to the child Listener.
-
Constructor Details
-
FormatTrackingHSSFListener
Creates a format tracking wrapper around the given listener, using thedefault locale
for the formats.- Parameters:
childListener
- the listener to be wrapped
-
FormatTrackingHSSFListener
Creates a format tracking wrapper around the given listener, using the given locale for the formats.- Parameters:
childListener
- the listener to be wrappedlocale
- the locale for the formats
-
-
Method Details
-
getNumberOfCustomFormats
protected int getNumberOfCustomFormats() -
getNumberOfExtendedFormats
protected int getNumberOfExtendedFormats() -
processRecord
Process this record ourselves, and then pass it on to our child listener- Specified by:
processRecord
in interfaceHSSFListener
- Parameters:
record
- the record to be processed
-
processRecordInternally
Process the record ourselves, but do not pass it on to the child Listener.- Parameters:
record
- the record to be processed
-
formatNumberDateCell
Formats the given numeric of date cells contents as a String, in as close as we can to the way that Excel would do so. Uses the various format records to manage this. TODO - move this to a central class in such a way that hssf.usermodel can make use of it too- Parameters:
cell
- the cell- Returns:
- the given numeric of date cells contents as a String
-
getFormatString
Returns the format string, eg $##.##, for the given number format index.- Parameters:
formatIndex
- the format index- Returns:
- the format string
-
getFormatString
Returns the format string, eg $##.##, used by your cell- Parameters:
cell
- the cell- Returns:
- the format string
-
getFormatIndex
Returns the index of the format string, used by your cell, or -1 if none found- Parameters:
cell
- the cell- Returns:
- the index of the format string
-