Example #1
0
 public String ResolveNameXText(NameXPtg n)
 {
     int idx = n.NameIndex;
     IndexedUDFFinder udfFinder = (IndexedUDFFinder)GetUDFFinder();
     return udfFinder.GetFunctionName(idx);
 }
 public String ResolveNameXText(NameXPtg n)
 {
     return _iBook.ResolveNameXText(n.SheetRefIndex, n.NameIndex);
 }
 public ValueEval GetNameXEval(NameXPtg nameXPtg)
 {
     ExternalSheet externSheet = _workbook.GetExternalSheet(nameXPtg.SheetRefIndex);
     if (externSheet == null)
         return new NameXEval(nameXPtg);
     String workbookName = externSheet.GetWorkbookName();
     ExternalName externName = _workbook.GetExternalName(
           nameXPtg.SheetRefIndex,
           nameXPtg.NameIndex
     );
     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");
             }
             Ptg ptg = evaluationName.NameDefinition[0];
             if (ptg is Ref3DPtg)
             {
                 Ref3DPtg ref3D = (Ref3DPtg)ptg;
                 int sheetIndex = refWorkbookEvaluator.GetSheetIndexByExternIndex(ref3D.ExternSheetIndex);
                 String sheetName = refWorkbookEvaluator.GetSheetName(sheetIndex);
                 SheetRefEvaluator sre = CreateExternSheetRefEvaluator(workbookName, sheetName);
                 return new LazyRefEval(ref3D.Row, ref3D.Column, sre);
             }
             else if (ptg is Area3DPtg)
             {
                 Area3DPtg area3D = (Area3DPtg)ptg;
                 int sheetIndex = refWorkbookEvaluator.GetSheetIndexByExternIndex(area3D.ExternSheetIndex);
                 String sheetName = refWorkbookEvaluator.GetSheetName(sheetIndex);
                 SheetRefEvaluator sre = CreateExternSheetRefEvaluator(workbookName, sheetName);
                 return new LazyAreaEval(area3D.FirstRow, area3D.FirstColumn, area3D.LastRow, area3D.LastColumn, sre);
             }
         }
         return ErrorEval.REF_INVALID;
     }
     catch (WorkbookNotFoundException)
     {
         return ErrorEval.REF_INVALID;
     }
 }
Example #4
0
 public String ResolveNameXText(NameXPtg nameXPtg)
 {
     return _fpwb.ResolveNameXText(nameXPtg);
 }
Example #5
0
 public NameXEval(NameXPtg ptg)
 {
     _ptg = ptg;
 }
        public String ResolveNameXText(NameXPtg n)
        {
            int idx = n.NameIndex;
            String name = null;

            // First, try to find it as a User Defined Function
            IndexedUDFFinder udfFinder = (IndexedUDFFinder)GetUDFFinder();
            name = udfFinder.GetFunctionName(idx);
            if (name != null) return name;

            // Otherwise, try it as a named range
            IName xname = _uBook.GetNameAt(idx);
            if (xname != null)
            {
                name = xname.NameName;
            }

            return name;
        }
        private ValueEval GetLocalNameXEval(NameXPtg nameXPtg)
        {
            String name = _workbook.ResolveNameXText(nameXPtg);

            // Try to parse it as a name
            int sheetNameAt = name.IndexOf('!');
            IEvaluationName evalName = null;
            if (sheetNameAt > -1)
            {
                // Sheet based name
                String sheetName = name.Substring(0, sheetNameAt);
                String nameName = name.Substring(sheetNameAt + 1);
                evalName = _workbook.GetName(nameName, _workbook.GetSheetIndex(sheetName));
            }
            else
            {
                // Workbook based name
                evalName = _workbook.GetName(name, -1);
            }

            if (evalName != null)
            {
                // Process it as a name
                return new ExternalNameEval(evalName);
            }
            else
            {
                // Must be an external function
                return new FunctionNameEval(name);
            }
        }
 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);
 }