/**
         * Creates a FormatRecord, Inserts it, and returns the index code.
         * @param format the format string
         * @return the index code of the format record.
         * @see org.apache.poi.hssf.record.FormatRecord
         * @see org.apache.poi.hssf.record.Record
         */
        public int CreateFormat(String formatString)
        {
            //        ++xfpos;	//These are to Ensure that positions are updated properly
            //        ++palettepos;
            //        ++bspos;
            maxformatid = maxformatid >= (short)0xa4 ? (short)(maxformatid + 1) : (short)0xa4; //Starting value from M$ empiracle study.
            FormatRecord rec = new FormatRecord(maxformatid, formatString);

            int pos = 0;
            while (pos < records.Count && records[pos].Sid != FormatRecord.sid)
                pos++;
            pos += formats.Count;
            formats.Add(rec);
            records.Add(pos, rec);
            return maxformatid;
        }
Exemple #2
0
        /**
         * Creates a FormatRecord object
         * @param id    the number of the format record to Create (meaning its position in
         *        a file as M$ Excel would Create it.)
         * @return record containing a FormatRecord
         * @see org.apache.poi.hssf.record.FormatRecord
         * @see org.apache.poi.hssf.record.Record
         */

        protected Record CreateFormat(int id)
        {   // we'll need multiple editions for
            FormatRecord retval = new FormatRecord();   // the differnt formats

            switch (id)
            {

                case 0:
                    retval.SetIndexCode((short)5);
                    retval.SetFormatStringLength((byte)0x17);
                    retval.SetFormatString("\"$\"#,##0_);\\(\"$\"#,##0\\)");
                    break;

                case 1:
                    retval.SetIndexCode((short)6);
                    retval.SetFormatStringLength((byte)0x1c);
                    retval.SetFormatString("\"$\"#,##0_);[Red]\\(\"$\"#,##0\\)");
                    break;

                case 2:
                    retval.SetIndexCode((short)7);
                    retval.SetFormatStringLength((byte)0x1d);
                    retval.SetFormatString("\"$\"#,##0.00_);\\(\"$\"#,##0.00\\)");
                    break;

                case 3:
                    retval.SetIndexCode((short)8);
                    retval.SetFormatStringLength((byte)0x22);
                    retval.SetFormatString(
                    "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)");
                    break;

                case 4:
                    retval.SetIndexCode((short)0x2a);
                    retval.SetFormatStringLength((byte)0x32);
                    retval.SetFormatString(
                    "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)");
                    break;

                case 5:
                    retval.SetIndexCode((short)0x29);
                    retval.SetFormatStringLength((byte)0x29);
                    retval.SetFormatString(
                    "_(* #,##0_);_(* \\(#,##0\\);_(* \"-\"_);_(@_)");
                    break;

                case 6:
                    retval.SetIndexCode((short)0x2c);
                    retval.SetFormatStringLength((byte)0x3a);
                    retval.SetFormatString(
                    "_(\"$\"* #,##0.00_);_(\"$\"* \\(#,##0.00\\);_(\"$\"* \"-\"??_);_(@_)");
                    break;

                case 7:
                    retval.SetIndexCode((short)0x2b);
                    retval.SetFormatStringLength((byte)0x31);
                    retval.SetFormatString(
                    "_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)");
                    break;
            }
            return retval;
        }
Exemple #3
0
        /**
         * Creates a FormatRecord, Inserts it, and returns the index code.
         * @param format the format string
         * @return the index code of the format record.
         * @see org.apache.poi.hssf.record.FormatRecord
         * @see org.apache.poi.hssf.record.Record
         */
        public short CreateFormat(String format)
        {
            //        ++xfpos;	//These are to Ensure that positions are updated properly
            //        ++palettepos;
            //        ++bspos;
            FormatRecord rec = new FormatRecord();
            maxformatid = maxformatid >= (short)0xa4 ? (short)(maxformatid + 1) : (short)0xa4; //Starting value from M$ empiracle study.
            rec.SetIndexCode(maxformatid);
            rec.SetFormatStringLength((byte)format.Length);
            rec.SetFormatString(format);

            int pos = 0;
            while (pos < records.Count && records[pos].Sid != FormatRecord.sid)
                pos++;
            pos += formats.Count;
            formats.Add(rec);
            records.Add(pos, rec);
            return maxformatid;
        }
Exemple #4
0
 private FormatRecord(FormatRecord other)
 {
     field_1_index_code   = other.field_1_index_code;
     field_3_hasMultibyte = other.field_3_hasMultibyte;
     field_4_formatstring = other.field_4_formatstring;
 }