/**
  * Process the record ourselves, but do not pass it on to the child Listener.
  *
  * @param record
  */
 public void processRecordInternally(Record record) {
   if (record instanceof FormatRecord) {
     FormatRecord fr = (FormatRecord) record;
     _customFormatRecords.put(Integer.valueOf(fr.getIndexCode()), fr);
   }
   if (record instanceof ExtendedFormatRecord) {
     ExtendedFormatRecord xr = (ExtendedFormatRecord) record;
     _xfRecords.add(xr);
   }
 }
Пример #2
0
  /**
   * Constructs a new data formatter. It takes a workbook to have access to the workbooks format
   * records.
   *
   * @param workbook the workbook the formats are tied to.
   */
  HSSFDataFormat(InternalWorkbook workbook) {
    _workbook = workbook;

    Iterator<FormatRecord> i = workbook.getFormats().iterator();
    while (i.hasNext()) {
      FormatRecord r = i.next();
      ensureFormatsSize(r.getIndexCode());
      _formats.set(r.getIndexCode(), r.getFormatString());
    }
  }
 /** Returns the format string, eg $##.##, for the given number format index. */
 public String getFormatString(int formatIndex) {
   String format = null;
   if (formatIndex >= HSSFDataFormat.getNumberOfBuiltinBuiltinFormats()) {
     FormatRecord tfr = _customFormatRecords.get(Integer.valueOf(formatIndex));
     if (tfr == null) {
       logger.log(
           POILogger.ERROR, "Requested format at index " + formatIndex + ", but it wasn't found");
     } else {
       format = tfr.getFormatString();
     }
   } else {
     format = HSSFDataFormat.getBuiltinFormat((short) formatIndex);
   }
   return format;
 }