本文整理汇总了C#中NPOI.SS.Formula.PTG.Ptg.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Ptg.GetType方法的具体用法?C# Ptg.GetType怎么用?C# Ptg.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPOI.SS.Formula.PTG.Ptg
的用法示例。
在下文中一共展示了Ptg.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEvalForPtg
/**
* returns an appropriate Eval impl instance for the Ptg. The Ptg must be
* one of: Area3DPtg, AreaPtg, ReferencePtg, Ref3DPtg, IntPtg, NumberPtg,
* StringPtg, BoolPtg <br/>special Note: OperationPtg subtypes cannot be
* passed here!
*/
private ValueEval GetEvalForPtg(Ptg ptg, OperationEvaluationContext ec)
{
// consider converting all these (ptg is XxxPtg) expressions To (ptg.GetType() == XxxPtg.class)
if (ptg is NamePtg)
{
// named ranges, macro functions
NamePtg namePtg = (NamePtg)ptg;
IEvaluationName nameRecord = _workbook.GetName(namePtg);
if (nameRecord.IsFunctionName)
{
return new NameEval(nameRecord.NameText);
}
if (nameRecord.HasFormula)
{
return EvaluateNameFormula(nameRecord.NameDefinition, ec);
}
throw new Exception("Don't now how To evalate name '" + nameRecord.NameText + "'");
}
if (ptg is NameXPtg)
{
return ec.GetNameXEval(((NameXPtg)ptg));
}
if (ptg is IntPtg)
{
return new NumberEval(((IntPtg)ptg).Value);
}
if (ptg is NumberPtg)
{
return new NumberEval(((NumberPtg)ptg).Value);
}
if (ptg is StringPtg)
{
return new StringEval(((StringPtg)ptg).Value);
}
if (ptg is BoolPtg)
{
return BoolEval.ValueOf(((BoolPtg)ptg).Value);
}
if (ptg is ErrPtg)
{
return ErrorEval.ValueOf(((ErrPtg)ptg).ErrorCode);
}
if (ptg is MissingArgPtg)
{
return MissingArgEval.instance;
}
if (ptg is AreaErrPtg || ptg is RefErrorPtg
|| ptg is DeletedArea3DPtg || ptg is DeletedRef3DPtg)
{
return ErrorEval.REF_INVALID;
}
if (ptg is Ref3DPtg)
{
Ref3DPtg rptg = (Ref3DPtg)ptg;
return ec.GetRef3DEval(rptg.Row, rptg.Column, rptg.ExternSheetIndex);
}
if (ptg is Area3DPtg)
{
Area3DPtg aptg = (Area3DPtg)ptg;
return ec.GetArea3DEval(aptg.FirstRow, aptg.FirstColumn, aptg.LastRow, aptg.LastColumn, aptg.ExternSheetIndex);
}
if (ptg is RefPtg)
{
RefPtg rptg = (RefPtg)ptg;
return ec.GetRefEval(rptg.Row, rptg.Column);
}
if (ptg is AreaPtg)
{
AreaPtg aptg = (AreaPtg)ptg;
return ec.GetAreaEval(aptg.FirstRow, aptg.FirstColumn, aptg.LastRow, aptg.LastColumn);
}
if (ptg is UnknownPtg)
{
// POI uses UnknownPtg when the encoded Ptg array seems To be corrupted.
// This seems To occur in very rare cases (e.g. unused name formulas in bug 44774, attachment 21790)
// In any case, formulas are re-parsed before execution, so UnknownPtg should not Get here
throw new RuntimeException("UnknownPtg not allowed");
}
if (ptg is ExpPtg)
{
// ExpPtg is used for array formulas and shared formulas.
// it is currently unsupported, and may not even get implemented here
throw new RuntimeException("ExpPtg currently not supported");
}
throw new RuntimeException("Unexpected ptg class (" + ptg.GetType().Name + ")");
}
示例2: ConvertArrayNumber
private static Double ConvertArrayNumber(Ptg ptg, bool isPositive)
{
double value;
if (ptg is IntPtg)
{
value = ((IntPtg)ptg).Value;
}
else if (ptg is NumberPtg)
{
value = ((NumberPtg)ptg).Value;
}
else
{
throw new Exception("Unexpected ptg (" + ptg.GetType().Name + ")");
}
if (!isPositive)
{
value = -value;
}
return value;
}
示例3: CreateDeletedRef
private static Ptg CreateDeletedRef(Ptg ptg)
{
if (ptg is RefPtg)
{
return new RefErrorPtg();
}
if (ptg is Ref3DPtg)
{
Ref3DPtg rptg = (Ref3DPtg)ptg;
return new DeletedRef3DPtg(rptg.ExternSheetIndex);
}
if (ptg is AreaPtg)
{
return new AreaErrPtg();
}
if (ptg is Area3DPtg)
{
Area3DPtg area3DPtg = (Area3DPtg)ptg;
return new DeletedArea3DPtg(area3DPtg.ExternSheetIndex);
}
if (ptg is Ref3DPxg)
{
Ref3DPxg pxg = (Ref3DPxg)ptg;
return new Deleted3DPxg(pxg.ExternalWorkbookNumber, pxg.SheetName);
}
if (ptg is Area3DPxg)
{
Area3DPxg pxg = (Area3DPxg)ptg;
return new Deleted3DPxg(pxg.ExternalWorkbookNumber, pxg.SheetName);
}
throw new ArgumentException("Unexpected ref ptg class (" + ptg.GetType().Name + ")");
}