org.apache.poi.hssf.eventusermodel
Class FormatTrackingHSSFListener

java.lang.Object
  extended by org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener
All Implemented Interfaces:
HSSFListener

public class FormatTrackingHSSFListener
extends java.lang.Object
implements 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
FormatTrackingHSSFListener(HSSFListener childListener)
          Creates a format tracking wrapper around the given listener, using the default locale for the formats.
FormatTrackingHSSFListener(HSSFListener childListener, java.util.Locale locale)
          Creates a format tracking wrapper around the given listener, using the given locale for the formats.
 
Method Summary
 java.lang.String formatNumberDateCell(CellValueRecordInterface cell)
          Formats the given numeric of date Cell's contents as a String, in as close as we can to the way that Excel would do so.
 int getFormatIndex(CellValueRecordInterface cell)
          Returns the index of the format string, used by your cell, or -1 if none found
 java.lang.String getFormatString(CellValueRecordInterface cell)
          Returns the format string, eg $##.##, used by your cell
 java.lang.String getFormatString(int formatIndex)
          Returns the format string, eg $##.##, for the given number format index.
protected  int getNumberOfCustomFormats()
           
protected  int getNumberOfExtendedFormats()
           
 void processRecord(Record record)
          Process this record ourselves, and then pass it on to our child listener
 void processRecordInternally(Record record)
          Process the record ourselves, but do not pass it on to the child Listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormatTrackingHSSFListener

public FormatTrackingHSSFListener(HSSFListener childListener)
Creates a format tracking wrapper around the given listener, using the default locale for the formats.


FormatTrackingHSSFListener

public FormatTrackingHSSFListener(HSSFListener childListener,
                                  java.util.Locale locale)
Creates a format tracking wrapper around the given listener, using the given locale for the formats.

Method Detail

getNumberOfCustomFormats

protected int getNumberOfCustomFormats()

getNumberOfExtendedFormats

protected int getNumberOfExtendedFormats()

processRecord

public void processRecord(Record record)
Process this record ourselves, and then pass it on to our child listener

Specified by:
processRecord in interface HSSFListener

processRecordInternally

public void processRecordInternally(Record record)
Process the record ourselves, but do not pass it on to the child Listener.

Parameters:
record -

formatNumberDateCell

public java.lang.String formatNumberDateCell(CellValueRecordInterface cell)
Formats the given numeric of date Cell's 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


getFormatString

public java.lang.String getFormatString(int formatIndex)
Returns the format string, eg $##.##, for the given number format index.


getFormatString

public java.lang.String getFormatString(CellValueRecordInterface cell)
Returns the format string, eg $##.##, used by your cell


getFormatIndex

public int getFormatIndex(CellValueRecordInterface cell)
Returns the index of the format string, used by your cell, or -1 if none found



Copyright 2012 The Apache Software Foundation or its licensors, as applicable.