Package org.apache.poi.hssf.record

Examples of org.apache.poi.hssf.record.FormatRecord


   *
   * @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);
    }
View Full Code Here


   * 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;
View Full Code Here

   *
   * @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);
    }
View Full Code Here

   * 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) {
        System.err.println("Requested format at index " + formatIndex
            + ", but it wasn't found");
      } else {
        format = tfr.getFormatString();
      }
    } else {
      format = HSSFDataFormat.getBuiltinFormat((short) formatIndex);
    }
    return format;
View Full Code Here

    _workbook = workbook;

    @SuppressWarnings("unchecked")
    Iterator<FormatRecord> i = workbook.getFormats().iterator();
    while (i.hasNext()) {
      FormatRecord r = i.next();
      ensureFormatsSize(r.getIndexCode());
      _formats.set(r.getIndexCode(), r.getFormatString());
    }
  }
View Full Code Here

        retval.records.setFontpos( records.size() - 1 );   // last font record position
        retval.numfonts = 4;

        // set up format records
        for (int i = 0; i <= 7; i++) {
            FormatRecord rec = createFormat(i);
            retval.maxformatid = retval.maxformatid >= rec.getIndexCode() ? retval.maxformatid : rec.getIndexCode();
            formats.add(rec);
            records.add(rec);
        }

        for (int k = 0; k < 21; k++) {
View Full Code Here

        // we'll need multiple editions for
        // the different formats

       
        switch (id) {
            case 0: return new FormatRecord(5, BuiltinFormats.getBuiltinFormat(5));
            case 1: return new FormatRecord(6, BuiltinFormats.getBuiltinFormat(6));
            case 2: return new FormatRecord(7, BuiltinFormats.getBuiltinFormat(7));
            case 3: return new FormatRecord(8, BuiltinFormats.getBuiltinFormat(8));
            case 4: return new FormatRecord(0x2a, BuiltinFormats.getBuiltinFormat(0x2a));
            case 5: return new FormatRecord(0x29, BuiltinFormats.getBuiltinFormat(0x29));
            case 6: return new FormatRecord(0x2c, BuiltinFormats.getBuiltinFormat(0x2c));
            case 7: return new FormatRecord(0x2b, BuiltinFormats.getBuiltinFormat(0x2b));
        }
        throw new  IllegalArgumentException("Unexpected id " + id);
    }
View Full Code Here

     * @see org.apache.poi.hssf.record.Record
     */
    public int createFormat(String formatString) {

        maxformatid = maxformatid >= 0xa4 ? maxformatid + 1 : 0xa4; //Starting value from M$ empircal study.
        FormatRecord rec = new FormatRecord(maxformatid, formatString);

        int pos = 0;
        while ( pos < records.size() && records.get( pos ).getSid() != FormatRecord.sid )
            pos++;
        pos += formats.size();
View Full Code Here

    _workbook = workbook;

    @SuppressWarnings("unchecked")
    Iterator<FormatRecord> i = workbook.getFormats().iterator();
    while (i.hasNext()) {
      FormatRecord r = i.next();
      if (_formats.size() < r.getIndexCode() + 1) {
        _formats.setSize(r.getIndexCode() + 1);
      }
      _formats.set(r.getIndexCode(), r.getFormatString());
    }
  }
View Full Code Here

        retval.records.setFontpos( records.size() - 1 );   // last font record position
        retval.numfonts = 4;

        // set up format records
        for (int i = 0; i <= 7; i++) {
            FormatRecord rec = createFormat(i);
            retval.maxformatid = retval.maxformatid >= rec.getIndexCode() ? retval.maxformatid : rec.getIndexCode();
            formats.add(rec);
            records.add(rec);
        }

        for (int k = 0; k < 21; k++) {
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.FormatRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.