Пример #1
0
        public void Recalc(TCellList CellList, ExcelFile aXls, int SheetIndexBase1)
        {
            //Do this loop in normal order, not reversed, to help avoid stack overflows. Normally references grow down and to the right
            //(for example cell A2 = "A1+1"). If we do the loop in reverse, we start by A900, and to calculate it we need A899 so we need A898...
            //And this can lead to an stack overflow error. Of course this is no guarantee, an user migh have A2= A3-1, etc, but that is less likely.

            TFormulaRecord r = FirstFormula;

            while (r != null)
            {
                if (aXls != null)
                {
                    aXls.SetUnsupportedFormulaCellAddress(new TCellAddress(aXls.GetSheetName(SheetIndexBase1), r.FRow + 1, r.Col + 1, false, false));
                }

                TCalcState     CalcState = new TCalcState();
                TFormulaRecord rPrev     = r.Prev; //r.prev won't be modified by Recalc, as it has already been recalculated
                r.Recalc(CellList, aXls, SheetIndexBase1, CalcState, new TCalcStack());

                if (rPrev == null)
                {
                    r = FirstFormula;
                }
                else
                {
                    r = rPrev.Next;                                       //Recalc might reorder the calc chain, so we want the next in the chain position, not the next to the modified r..
                }
                r = r.Next;
            }
        }
Пример #2
0
        internal override object Evaluate(TParsedTokenList FTokenList, TWorkbookInfo wi, TBaseAggregate f, TCalcState STotal, TCalcStack CalcStack)
        {
            TValueAndXF val = new TValueAndXF();

            val.FullDataSetColumnIndex = wi.FullDataSetIndex;
            val.Workbook   = wi.Xls;
            val.DebugStack = wi.DebugStack;
            Data.Evaluate(wi.Row, wi.Col, wi.RowOfs, wi.ColOfs, val);
            return(ConvertToAllowedObject(val.Value));
        }