Ejemplo n.º 1
0
        /**
         * Manufactures individual cell formulas out the whole shared formula
         * debacle
         *
         * @param fr the formatting records
         * @param nf flag indicating whether this uses the 1904 date system
         * @return an array of formulas to be added to the sheet
         */
        public Cell[] getFormulas(FormattingRecords fr, bool nf)
        {
            Cell[] sfs = new Cell[formulas.Count + 1];

            // This can happen if there are many identical formulas in the
            // sheet and excel has not sliced and diced them exclusively
            if (templateFormula == null)
            {
                //logger.warn("Shared formula template formula is null");
                return(new Cell[0]);
            }

            templateFormula.setTokens(tokens);
            NumberFormat templateNumberFormat = null;

            // See if the template formula evaluates to date
            if (templateFormula.getType() == CellType.NUMBER_FORMULA)
            {
                SharedNumberFormulaRecord snfr = (SharedNumberFormulaRecord)
                                                 templateFormula;
                templateNumberFormat = snfr.getNumberFormat();

                if (fr.isDate(templateFormula.getXFIndex()))
                {
                    templateFormula = new SharedDateFormulaRecord(snfr, fr, nf, sheet,
                                                                  snfr.getFilePos());
                    templateFormula.setTokens(snfr.getTokens());
                }
            }

            sfs[0] = templateFormula;

            BaseSharedFormulaRecord f = null;

            for (int i = 0; i < formulas.Count; i++)
            {
                f = (BaseSharedFormulaRecord)formulas[i];

                // See if the formula evaluates to date
                if (f.getType() == CellType.NUMBER_FORMULA)
                {
                    SharedNumberFormulaRecord snfr = (SharedNumberFormulaRecord)f;

                    if (fr.isDate(f.getXFIndex()))
                    {
                        f = new SharedDateFormulaRecord(snfr, fr, nf, sheet,
                                                        snfr.getFilePos());
                    }
                    else
                    {
                        ;                        // snfr.setNumberFormat(templateNumberFormat);
                    }
                }

                f.setTokens(tokens);
                sfs[i + 1] = f;
            }

            return(sfs);
        }
        /**
         * Manufactures individual cell formulas out the whole shared formula
         * debacle
         *
         * @param fr the formatting records
         * @param nf flag indicating whether this uses the 1904 date system
         * @return an array of formulas to be added to the sheet
         */
        public Cell[] getFormulas(FormattingRecords fr, bool nf)
        {
            Cell[] sfs = new Cell[formulas.Count + 1];

            // This can happen if there are many identical formulas in the
            // sheet and excel has not sliced and diced them exclusively
            if (templateFormula == null)
                {
                //logger.warn("Shared formula template formula is null");
                return new Cell[0];
                }

            templateFormula.setTokens(tokens);
            NumberFormat templateNumberFormat = null;

            // See if the template formula evaluates to date
            if (templateFormula.getType() == CellType.NUMBER_FORMULA)
                {
                SharedNumberFormulaRecord snfr = (SharedNumberFormulaRecord)
                  templateFormula;
                templateNumberFormat = snfr.getNumberFormat();

                if (fr.isDate(templateFormula.getXFIndex()))
                    {
                    templateFormula = new SharedDateFormulaRecord(snfr,fr,nf,sheet,
                                                                  snfr.getFilePos());
                    templateFormula.setTokens(snfr.getTokens());
                    }
                }

            sfs[0] = templateFormula;

            BaseSharedFormulaRecord f = null;

            for (int i = 0; i < formulas.Count; i++)
                {
                f = (BaseSharedFormulaRecord)formulas[i];

                // See if the formula evaluates to date
                if (f.getType() == CellType.NUMBER_FORMULA)
                    {
                    SharedNumberFormulaRecord snfr = (SharedNumberFormulaRecord)f;

                    if (fr.isDate(f.getXFIndex()))
                        {
                        f = new SharedDateFormulaRecord(snfr,fr,nf,sheet,
                                                        snfr.getFilePos());
                        }
                    else
                        {
                        ;// snfr.setNumberFormat(templateNumberFormat);
                        }
                    }

                f.setTokens(tokens);
                sfs[i + 1] = f;
                }

            return sfs;
        }