private SheetRangeEvaluator CreateExternSheetRefEvaluator(ExternalSheet externalSheet)
        {
            WorkbookEvaluator targetEvaluator;
            int otherFirstSheetIndex;
            int otherLastSheetIndex = -1;

            if (externalSheet == null || externalSheet.WorkbookName == null)
            {
                // sheet is in same workbook
                targetEvaluator      = _bookEvaluator;
                otherFirstSheetIndex = _workbook.GetSheetIndex(externalSheet.SheetName);

                if (externalSheet is ExternalSheetRange)
                {
                    string lastSheetName = ((ExternalSheetRange)externalSheet).LastSheetName;
                    otherLastSheetIndex = _workbook.GetSheetIndex(lastSheetName);
                }
            }
            else
            {
                // look up sheet by name from external workbook
                string workbookName = externalSheet.WorkbookName;
                try
                {
                    targetEvaluator = _bookEvaluator.GetOtherWorkbookEvaluator(workbookName);
                }
                catch (WorkbookNotFoundException e)
                {
                    throw new RuntimeException(e.Message, e);
                }

                otherFirstSheetIndex = targetEvaluator.GetSheetIndex(externalSheet.SheetName);
                if (externalSheet is ExternalSheetRange)
                {
                    string lastSheetName = ((ExternalSheetRange)externalSheet).LastSheetName;
                    otherLastSheetIndex = targetEvaluator.GetSheetIndex(lastSheetName);
                }

                if (otherFirstSheetIndex < 0)
                {
                    throw new Exception("Invalid sheet name '" + externalSheet.SheetName
                                        + "' in bool '" + workbookName + "'.");
                }
            }

            if (otherLastSheetIndex == -1)
            {
                // Reference to just one sheet
                otherLastSheetIndex = otherFirstSheetIndex;
            }

            SheetRefEvaluator[] Evals = new SheetRefEvaluator[otherLastSheetIndex - otherFirstSheetIndex + 1];
            for (int i = 0; i < Evals.Length; i++)
            {
                int otherSheetIndex = i + otherFirstSheetIndex;
                Evals[i] = new SheetRefEvaluator(targetEvaluator, _tracker, otherSheetIndex);
            }
            return(new SheetRangeEvaluator(otherFirstSheetIndex, otherLastSheetIndex, Evals));
        }
        public ValueEval GetNameXEval(NameXPtg nameXPtg)
        {
            ExternalSheet externSheet = _workbook.GetExternalSheet(nameXPtg.SheetRefIndex);

            if (externSheet == null || externSheet.WorkbookName == null)
            {
                // External reference to our own workbook's name
                return(GetLocalNameXEval(nameXPtg));
            }
            // Look it up for the external workbook
            string       workbookName = externSheet.WorkbookName;
            ExternalName externName   = _workbook.GetExternalName(
                nameXPtg.SheetRefIndex,
                nameXPtg.NameIndex
                );

            return(GetExternalNameXEval(externName, workbookName));
        }
Exemplo n.º 3
0
        public ValueEval GetNameXEval(NameXPxg nameXPxg)
        {
            ExternalSheet externSheet = _workbook.GetExternalSheet(nameXPxg.SheetName, null, nameXPxg.ExternalWorkbookNumber);

            if (externSheet == null || externSheet.WorkbookName == null)
            {
                // External reference to our own workbook's name
                return(GetLocalNameXEval(nameXPxg));
            }

            // Look it up for the external workbook
            String       workbookName = externSheet.WorkbookName;
            ExternalName externName   = _workbook.GetExternalName(
                nameXPxg.NameName,
                nameXPxg.SheetName,
                nameXPxg.ExternalWorkbookNumber
                );

            return(GetExternalNameXEval(externName, workbookName));
        }
        private SheetRangeEvaluator CreateExternSheetRefEvaluator(int externSheetIndex)
        {
            ExternalSheet externalSheet = _workbook.GetExternalSheet(externSheetIndex);

            return(CreateExternSheetRefEvaluator(externalSheet));
        }
        private SheetRangeEvaluator CreateExternSheetRefEvaluator(string firstSheetName, string lastSheetName, int externalWorkbookNumber)
        {
            ExternalSheet externalSheet = _workbook.GetExternalSheet(firstSheetName, lastSheetName, externalWorkbookNumber);

            return(CreateExternSheetRefEvaluator(externalSheet));
        }