Пример #1
0
        /**
         * Constructs this object from the raw data.  Creates either a
         * NumberFormulaRecord or a StringFormulaRecord depending on whether
         * this formula represents a numerical calculation or not
         *
         * @param t the raw data
         * @param excelFile the excel file
         * @param fr the formatting records
         * @param es the workbook, which contains the external sheet references
         * @param nt the name table
         * @param i a dummy override to indicate that we don't want to do
         * any shared formula processing
         * @param si the sheet impl
         * @param ws the workbook settings
         */
        public FormulaRecord(Record t,
                             File excelFile,
                             FormattingRecords fr,
                             ExternalSheet es,
                             WorkbookMethods nt,
                             IgnoreSharedFormula i,
                             SheetImpl si,
                             WorkbookSettings ws)
            : base(t, fr, si)
        {
            byte[] data = getRecord().getData();

            shared = false;

            // microsoft and their magic values determine whether this
            // is a string or a number value
            if (data[6] == 0 && data[12] == 0xff && data[13] == 0xff)
            {
                // we have a string
                formula = new StringFormulaRecord(t, excelFile, fr, es, nt, si, ws);
            }
            else if (data[6] == 1 &&
                     data[12] == 0xff &&
                     data[13] == 0xff)
            {
                // We have a bool formula
                // multiple values.  Thanks to Frank for spotting this
                formula = new BooleanFormulaRecord(t, fr, es, nt, si);
            }
            else if (data[6] == 2 &&
                     data[12] == 0xff &&
                     data[13] == 0xff)
            {
                // The cell is in error
                formula = new ErrorFormulaRecord(t, fr, es, nt, si);
            }
            else
            {
                // it is most assuredly a number
                formula = new NumberFormulaRecord(t, fr, es, nt, si);
            }
        }
Пример #2
0
        /**
         * Constructs this object from the raw data.  Creates either a
         * NumberFormulaRecord or a StringFormulaRecord depending on whether
         * this formula represents a numerical calculation or not
         *
         * @param t the raw data
         * @param excelFile the excel file
         * @param fr the formatting records
         * @param es the workbook, which contains the external sheet references
         * @param nt the name table
         * @param i a dummy override to indicate that we don't want to do
         * any shared formula processing
         * @param si the sheet impl
         * @param ws the workbook settings
         */
        public FormulaRecord(Record t,
            File excelFile,
            FormattingRecords fr,
            ExternalSheet es,
            WorkbookMethods nt,
            IgnoreSharedFormula i,
            SheetImpl si,
            WorkbookSettings ws)
            : base(t,fr,si)
        {
            byte[] data = getRecord().getData();

            shared = false;

            // microsoft and their magic values determine whether this
            // is a string or a number value
            if (data[6] == 0 && data[12] == 0xff && data[13] == 0xff)
                {
                // we have a string
                formula = new StringFormulaRecord(t,excelFile,fr,es,nt,si,ws);
                }
            else if (data[6] == 1 &&
                data[12] == 0xff &&
                data[13] == 0xff)
                {
                // We have a bool formula
                // multiple values.  Thanks to Frank for spotting this
                formula = new BooleanFormulaRecord(t,fr,es,nt,si);
                }
            else if (data[6] == 2 &&
                data[12] == 0xff &&
                data[13] == 0xff)
                {
                // The cell is in error
                formula = new ErrorFormulaRecord(t,fr,es,nt,si);
                }
            else
                {
                // it is most assuredly a number
                formula = new NumberFormulaRecord(t,fr,es,nt,si);
                }
        }