// Fetch the workbook this refers to, and the name as defined with that
        private ValueEval GetExternalNameXEval(ExternalName externName, string workbookName)
        {
            try
            {
                WorkbookEvaluator refWorkbookEvaluator = _bookEvaluator.GetOtherWorkbookEvaluator(workbookName);
                IEvaluationName   evaluationName       = refWorkbookEvaluator.GetName(externName.Name, externName.Ix - 1);
                if (evaluationName != null && evaluationName.HasFormula)
                {
                    if (evaluationName.NameDefinition.Length > 1)
                    {
                        throw new Exception("Complex name formulas not supported yet");
                    }
                    // Need to Evaluate the reference in the context of the other book
                    OperationEvaluationContext refWorkbookContext = new OperationEvaluationContext(
                        refWorkbookEvaluator, refWorkbookEvaluator.Workbook, -1, -1, -1, _tracker);

                    Ptg ptg = evaluationName.NameDefinition[0];
                    if (ptg is Ref3DPtg)
                    {
                        Ref3DPtg ref3D = (Ref3DPtg)ptg;
                        return(refWorkbookContext.GetRef3DEval(ref3D));
                    }
                    else if (ptg is Ref3DPxg)
                    {
                        Ref3DPxg ref3D = (Ref3DPxg)ptg;
                        return(refWorkbookContext.GetRef3DEval(ref3D));
                    }
                    else if (ptg is Area3DPtg)
                    {
                        Area3DPtg area3D = (Area3DPtg)ptg;
                        return(refWorkbookContext.GetArea3DEval(area3D));
                    }
                    else if (ptg is Area3DPxg)
                    {
                        Area3DPxg area3D = (Area3DPxg)ptg;
                        return(refWorkbookContext.GetArea3DEval(area3D));
                    }
                }
                return(ErrorEval.REF_INVALID);
            }
            catch (WorkbookNotFoundException)
            {
                return(ErrorEval.REF_INVALID);
            }
        }
        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));
        }
예제 #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));
        }