当前位置: 首页>>代码示例>>C#>>正文


C# PTG.Ptg类代码示例

本文整理汇总了C#中NPOI.SS.Formula.PTG.Ptg的典型用法代码示例。如果您正苦于以下问题:C# Ptg类的具体用法?C# Ptg怎么用?C# Ptg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Ptg类属于NPOI.SS.Formula.PTG命名空间,在下文中一共展示了Ptg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfirmRefErr

        private static void ConfirmRefErr(Ptg ptg)
        {
            Ptg[] ptgs = { ptg };

            ValueEval result = EvaluateFormula(ptgs);
            Assert.AreEqual(ErrorEval.REF_INVALID, result);
        }
开发者ID:89sos98,项目名称:npoi,代码行数:7,代码来源:TestWorkbookEvaluator.cs

示例2: ConfirmAttrData

 private static void ConfirmAttrData(Ptg[] ptgs, int i, int expectedData)
 {
     Ptg ptg = ptgs[i];
     if (!(ptg is AttrPtg))
     {
         throw new AssertionException("Token[" + i + "] was not AttrPtg as expected");
     }
     AttrPtg attrPtg = (AttrPtg)ptg;
     Assert.AreEqual(expectedData, attrPtg.Data);
 }
开发者ID:89sos98,项目名称:npoi,代码行数:10,代码来源:TestFormulaParserIf.cs

示例3: NumberEval

 public NumberEval(Ptg ptg)
 {
     if (ptg is IntPtg)
     {
         this._value = ((IntPtg)ptg).Value;
     }
     else if (ptg is NumberPtg)
     {
         this._value = ((NumberPtg)ptg).Value;
     }
 }
开发者ID:xoposhiy,项目名称:npoi,代码行数:11,代码来源:NumberEval.cs

示例4: ParseNode

 public ParseNode(Ptg token, ParseNode[] children)
 {
     _token = token;
     _children = children;
     _isIf = IsIf(token);
     int tokenCount = 1;
     for (int i = 0; i < children.Length; i++)
     {
         tokenCount += children[i].TokenCount;
     }
     if (_isIf)
     {
         // there will be 2 or 3 extra tAttr Tokens according To whether the false param is present
         tokenCount += children.Length;
     }
     _tokenCount = tokenCount;
 }
开发者ID:ctddjyds,项目名称:npoi,代码行数:17,代码来源:ParseNode.cs

示例5: ReduceRangeExpression

        /**
         * 
         * "A1", "B3" -> "A1:B3"   
         * "sheet1!A1", "B3" -> "sheet1!A1:B3"
         * 
         * @return <c>null</c> if the range expression cannot / shouldn't be reduced.
         */
        private static Ptg ReduceRangeExpression(Ptg ptgA, Ptg ptgB)
        {
            if (!(ptgB is RefPtg))
            {
                // only when second ref is simple 2-D ref can the range 
                // expression be converted To an area ref
                return null;
            }
            RefPtg refB = (RefPtg)ptgB;

            if (ptgA is RefPtg)
            {
                RefPtg refA = (RefPtg)ptgA;
                return new AreaPtg(refA.Row, refB.Row, refA.Column, refB.Column,
                        refA.IsRowRelative, refB.IsRowRelative, refA.IsColRelative, refB.IsColRelative);
            }
            if (ptgA is Ref3DPtg)
            {
                Ref3DPtg refA = (Ref3DPtg)ptgA;
                return new Area3DPtg(refA.Row, refB.Row, refA.Column, refB.Column,
                        refA.IsRowRelative, refB.IsRowRelative, refA.IsColRelative, refB.IsColRelative,
                        refA.ExternSheetIndex);
            }
            // Note - other operand types (like AreaPtg) which probably can't evaluate 
            // do not cause validation errors at Parse time
            return null;
        }
开发者ID:xoposhiy,项目名称:npoi,代码行数:34,代码来源:FormulaParser.cs

示例6: 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;
 }
开发者ID:xoposhiy,项目名称:npoi,代码行数:21,代码来源:FormulaParser.cs

示例7: Add

 public void Add(Ptg token)
 {
     if (token == null)
     {
         throw new ArgumentException("token must not be null");
     }
     _ptgs[_offset] = token;
     _offset++;
 }
开发者ID:ctddjyds,项目名称:npoi,代码行数:9,代码来源:ParseNode.cs

示例8: SetArrayFormula

        public void SetArrayFormula(CellRangeAddress r, Ptg[] ptgs)
        {

            ArrayRecord arr = new ArrayRecord(NPOI.SS.Formula.Formula.Create(ptgs), new CellRangeAddress8Bit(r.FirstRow, r.LastRow, r.FirstColumn, r.LastColumn));
            _sharedValueManager.AddArrayRecord(arr);
        }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:6,代码来源:FormulaRecordAggregate.cs

示例9: ConfirmOperandClasses

 private static void ConfirmOperandClasses(Ptg[] originalPtgs, Ptg[] convertedPtg)
 {
     Assert.AreEqual(originalPtgs.Length, convertedPtg.Length);
     for (int i = 0; i < convertedPtg.Length; i++)
     {
         Ptg originalPtg = originalPtgs[i];
         Ptg ConvertedPtg = convertedPtg[i];
         if (originalPtg.PtgClass != ConvertedPtg.PtgClass)
         {
             throw new ComparisonFailure("Different operand class for token[" + i + "]",
                     originalPtg.PtgClass.ToString(), ConvertedPtg.PtgClass.ToString());
         }
     }
 }
开发者ID:hanwangkun,项目名称:npoi,代码行数:14,代码来源:TestSharedFormulaRecord.cs

示例10: SetParsedExpression

 public void SetParsedExpression(Ptg[] ptgs)
 {
     field_5_name_definition = Formula.Create(ptgs);
 }
开发者ID:ctddjyds,项目名称:npoi,代码行数:4,代码来源:ExternalNameRecord.cs

示例11: ConfirmCell

        private void ConfirmCell(ICell formulaCell, String formula, HSSFWorkbook wb)
        {
            Ptg[] excelPtgs = FormulaExtractor.GetPtgs(formulaCell);
            Ptg[] poiPtgs = HSSFFormulaParser.Parse(formula, wb);
            int nExcelTokens = excelPtgs.Length;
            int nPoiTokens = poiPtgs.Length;
            if (nExcelTokens != nPoiTokens)
            {
                if (nExcelTokens == nPoiTokens + 1 && excelPtgs[0].GetType() == typeof(AttrPtg))
                {
                    // compensate for missing tAttrVolatile, which belongs in any formula 
                    // involving OFFSET() et al. POI currently does not insert where required
                    Ptg[] temp = new Ptg[nExcelTokens];
                    temp[0] = excelPtgs[0];
                    Array.Copy(poiPtgs, 0, temp, 1, nPoiTokens);
                    poiPtgs = temp;
                }
                else
                {
                    throw new Exception("Expected " + nExcelTokens + " tokens but got "
                            + nPoiTokens);
                }
            }
            bool hasMismatch = false;
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < nExcelTokens; i++)
            {
                Ptg poiPtg = poiPtgs[i];
                Ptg excelPtg = excelPtgs[i];
                if (excelPtg.GetType() != poiPtg.GetType())
                {
                    hasMismatch = true;
                    sb.Append("  mismatch token type[" + i + "] " + GetShortClassName(excelPtg) + " "
                            + excelPtg.RVAType + " - " + GetShortClassName(poiPtg) + " "
                            + poiPtg.RVAType);
                    sb.Append(Environment.NewLine);
                    continue;
                }
                if (poiPtg.IsBaseToken)
                {
                    continue;
                }
                sb.Append("  token[" + i + "] " + excelPtg.ToString() + " "
                        + excelPtg.RVAType);

                if (excelPtg.PtgClass != poiPtg.PtgClass)
                {
                    hasMismatch = true;
                    sb.Append(" - was " + poiPtg.RVAType);
                }
                sb.Append(Environment.NewLine);
            }
            //if (false)
            //{ // Set 'true' to see trace of RVA values
            //    Console.WriteLine(formula);
            //    Console.WriteLine(sb.ToString());
            //}
            if (hasMismatch)
            {
                throw new AssertionException(sb.ToString());
            }
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:62,代码来源:TestRVA.cs

示例12: ConfirmTokenClass

 private void ConfirmTokenClass(Ptg[] ptgs, int i, byte operandClass)
 {
     Ptg ptg = ptgs[i];
     if (ptg.IsBaseToken)
     {
         throw new AssertionException("ptg[" + i + "] is a base token");
     }
     if (operandClass != ptg.PtgClass)
     {
         throw new AssertionException("Wrong operand class for ptg ("
                 + ptg.ToString() + "). Expected " + GetOperandClassName(operandClass)
                 + " but got " + GetOperandClassName(ptg.PtgClass));
     }
 }
开发者ID:hanwangkun,项目名称:npoi,代码行数:14,代码来源:TestOperandClassTransformer.cs

示例13: GetEncodedSize

        /**
	 * This method will return the same result as {@link #getEncodedSizeWithoutArrayData(Ptg[])}
	 * if there are no array tokens present.
	 * @return the full size taken to encode the specified <c>Ptg</c>s
	 */
        public static int GetEncodedSize(Ptg[] ptgs)
        {
            int result = 0;
            for (int i = 0; i < ptgs.Length; i++)
            {
                result += ptgs[i].Size;
            }
            return result;
        }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:14,代码来源:Ptg.cs

示例14: ConfirmFuncClass

 private void ConfirmFuncClass(Ptg[] ptgs, int i, String expectedFunctionName, byte operandClass)
 {
     ConfirmTokenClass(ptgs, i, operandClass);
     AbstractFunctionPtg afp = (AbstractFunctionPtg)ptgs[i];
     Assert.AreEqual(expectedFunctionName, afp.Name);
 }
开发者ID:hanwangkun,项目名称:npoi,代码行数:6,代码来源:TestOperandClassTransformer.cs

示例15: EmbeddedObjectRefSubRecord

        /**
         * Constructs an EmbeddedObjectRef record and Sets its fields appropriately.
         *
         * @param in the record input stream.
         */
        public EmbeddedObjectRefSubRecord(ILittleEndianInput in1, int size)
        {
            // Much guess-work going on here due to lack of any documentation.
            // See similar source code in OOO:
            // http://lxr.go-oo.org/source/sc/sc/source/filter/excel/xiescher.cxx
            // 1223 void XclImpOleObj::ReadPictFmla( XclImpStream& rStrm, sal_uInt16 nRecSize )

            int streamIdOffset = in1.ReadShort(); // OOO calls this 'nFmlaLen'
            int remaining = size - LittleEndianConsts.SHORT_SIZE;

            int dataLenAfterFormula = remaining - streamIdOffset;
            int formulaSize = in1.ReadUShort();

            remaining -= LittleEndianConsts.SHORT_SIZE;
            field_1_unknown_int = in1.ReadInt();
            remaining -= LittleEndianConsts.INT_SIZE;
            byte[] formulaRawBytes = ReadRawData(in1, formulaSize);
            remaining -= formulaSize;
            field_2_refPtg = ReadRefPtg(formulaRawBytes);
            if (field_2_refPtg == null)
            {
                // common case
                // field_2_n16 seems to be 5 here
                // The formula almost looks like tTbl but the row/column values seem like garbage.
                field_2_unknownFormulaData = formulaRawBytes;
            }
            else
            {
                field_2_unknownFormulaData = null;
            }


            int stringByteCount;
            if (remaining >= dataLenAfterFormula + 3)
            {
                int tag = in1.ReadByte();
                stringByteCount = LittleEndianConsts.BYTE_SIZE;
                if (tag != 0x03)
                {
                    throw new RecordFormatException("Expected byte 0x03 here");
                }
                int nChars = in1.ReadUShort();
                stringByteCount += LittleEndianConsts.SHORT_SIZE;
                if (nChars > 0)
                {
                    // OOO: the 4th way Xcl stores a unicode string: not even a Grbit byte present if Length 0
                    field_3_unicode_flag = (in1.ReadByte() & 0x01) != 0;
                    stringByteCount += LittleEndianConsts.BYTE_SIZE;
                    if (field_3_unicode_flag)
                    {
                        field_4_ole_classname = StringUtil.ReadUnicodeLE(in1,nChars);
                        stringByteCount += nChars * 2;
                    }
                    else
                    {
                        field_4_ole_classname = StringUtil.ReadCompressedUnicode(in1,nChars);
                        stringByteCount += nChars;
                    }
                }
                else
                {
                    field_4_ole_classname = "";
                }
            }
            else
            {
                field_4_ole_classname = null;
                stringByteCount = 0;
            }
            remaining -= stringByteCount;
            // Pad to next 2-byte boundary
            if (((stringByteCount + formulaSize) % 2) != 0)
            {
                int b = in1.ReadByte();
                remaining -= LittleEndianConsts.BYTE_SIZE;
                if (field_2_refPtg != null && field_4_ole_classname == null)
                {
                    field_4_unknownByte = (byte)b;
                }
            }
            int nUnexpectedPadding = remaining - dataLenAfterFormula;

            if (nUnexpectedPadding > 0)
            {
                logger.Log(POILogger.ERROR, "Discarding " + nUnexpectedPadding + " unexpected padding bytes ");
                ReadRawData(in1, nUnexpectedPadding);
                remaining -= nUnexpectedPadding;
            }

            // Fetch the stream ID
            if (dataLenAfterFormula >= 4)
            {
                field_5_stream_id = in1.ReadInt();
                remaining -= LittleEndianConsts.INT_SIZE;
            }
//.........这里部分代码省略.........
开发者ID:Reinakumiko,项目名称:npoi,代码行数:101,代码来源:EmbeddedObjectRefSubRecord.cs


注:本文中的NPOI.SS.Formula.PTG.Ptg类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。