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


C# RecordInputStream.NextRecord方法代码示例

本文整理汇总了C#中NPOI.HSSF.Record.RecordInputStream.NextRecord方法的典型用法代码示例。如果您正苦于以下问题:C# RecordInputStream.NextRecord方法的具体用法?C# RecordInputStream.NextRecord怎么用?C# RecordInputStream.NextRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NPOI.HSSF.Record.RecordInputStream的用法示例。


在下文中一共展示了RecordInputStream.NextRecord方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StreamEncryptionInfo

			public StreamEncryptionInfo(RecordInputStream rs, List<Record> outputRecs)
			{
				Record rec;
				rs.NextRecord();
				int recSize = 4 + rs.Remaining;
				rec = RecordFactory.CreateSingleRecord(rs);
				outputRecs.Add(rec);
				FilePassRecord fpr = null;
				if (rec is BOFRecord)
				{
					_hasBOFRecord = true;
					// Fetch the next record, and see if it indicates whether
					//  the document is encrypted or not
					if (rs.HasNextRecord)
					{
						rs.NextRecord();
						rec = RecordFactory.CreateSingleRecord(rs);
						recSize += rec.RecordSize;
						outputRecs.Add(rec);
						// Encrypted is normally BOF then FILEPASS
						// May sometimes be BOF, WRITEPROTECT, FILEPASS
						if (rec is WriteProtectRecord && rs.HasNextRecord)
						{
							rs.NextRecord();
							rec = RecordFactory.CreateSingleRecord(rs);
							recSize += rec.RecordSize;
							outputRecs.Add(rec);
						}
						// If it's a FILEPASS, track it specifically but
						//  don't include it in the main stream
						if (rec is FilePassRecord)
						{
							fpr = (FilePassRecord)rec;
							outputRecs.RemoveAt(outputRecs.Count - 1);
							// TODO - add fpr not Added to outPutRecs
							rec = outputRecs[0];
						}
						else
						{
							// workbook not encrypted (typical case)
							if (rec is EOFRecord)
							{
								// A workbook stream is never empty, so crash instead
								// of trying to keep track of nesting level
								throw new InvalidOperationException("Nothing between BOF and EOF");
							}
						}
					}
				}
				else
				{
					// Invalid in a normal workbook stream.
					// However, some test cases work on sub-sections of
					// the workbook stream that do not begin with BOF
					_hasBOFRecord = false;
				}
				_InitialRecordsSize = recSize;
				_filePassRec = fpr;
				_lastRecord = rec;
			}
开发者ID:rohatsu,项目名称:npoi,代码行数:60,代码来源:RecordFactoryInputStream.cs

示例2: ObjRecord

        /**
         * Constructs a OBJ record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public ObjRecord(RecordInputStream in1)
        {
            subrecords = new ArrayList();
            //Check if this can be continued, if so then the
            //following wont work properly
            int subSize = 0;
            byte[] subRecordData = in1.ReadRemainder();

            RecordInputStream subRecStream = new RecordInputStream(new MemoryStream(subRecordData));
            while (subRecStream.HasNextRecord)
            {
                subRecStream.NextRecord();
                Record subRecord = SubRecord.CreateSubRecord(subRecStream);
                subSize += subRecord.RecordSize;
                subrecords.Add(subRecord);
            }

            /**
             * Add the EndSubRecord explicitly.
             * 
             * TODO - the reason the EndSubRecord Is always skipped Is because its 'sid' Is zero and
             * that causes subRecStream.HasNextRecord() to return false.
             * There may be more than the size of EndSubRecord left-over, if there Is any pAdding 
             * after that record.  The content of the EndSubRecord and the pAdding Is all zeros.
             * So there's not much to look at past the last substantial record.
             * 
             * See Bugs 41242/45133 for details.
             */
            if (subRecordData.Length - subSize >= 4)
            {
                subrecords.Add(new EndSubRecord());
            }
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:39,代码来源:ObjRecord.cs

示例3: TestRead

        public void TestRead()
        {

            byte[] data = new byte[22];
            LittleEndian.PutShort(data, 0, DVALRecord.sid);
            LittleEndian.PutShort(data, 2, (short)18);
            LittleEndian.PutShort(data, 4, (short)55);
            LittleEndian.PutInt(data, 6, 56);
            LittleEndian.PutInt(data, 10, 57);
            LittleEndian.PutInt(data, 14, 58);
            LittleEndian.PutInt(data, 18, 59);

            RecordInputStream in1 = new RecordInputStream(new MemoryStream(data));
            in1.NextRecord();
            DVALRecord dv = new DVALRecord(in1);

            Assert.AreEqual(55, dv.Options);
            Assert.AreEqual(56, dv.HorizontalPos);
            Assert.AreEqual(57, dv.VerticalPos);
            Assert.AreEqual(58, dv.ObjectID);
            if (dv.DVRecNo == 0)
            {
                Assert.Fail("Identified bug 44510");
            }
            Assert.AreEqual(59, dv.DVRecNo);
        }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:26,代码来源:TestDVALRecord.cs

示例4: StreamEncryptionInfo

 public StreamEncryptionInfo(RecordInputStream rs, List<Record> outputRecs)
 {
     Record rec;
     rs.NextRecord();
     int recSize = 4 + rs.Remaining;
     rec = RecordFactory.CreateSingleRecord(rs);
     outputRecs.Add(rec);
     FilePassRecord fpr = null;
     if (rec is BOFRecord)
     {
         _hasBOFRecord = true;
         if (rs.HasNextRecord)
         {
             rs.NextRecord();
             rec = RecordFactory.CreateSingleRecord(rs);
             recSize += rec.RecordSize;
             outputRecs.Add(rec);
             if (rec is FilePassRecord)
             {
                 fpr = (FilePassRecord)rec;
                 outputRecs.RemoveAt(outputRecs.Count - 1);
                 // TODO - add fpr not Added to outPutRecs
                 rec = outputRecs[0];
             }
             else
             {
                 // workbook not encrypted (typical case)
                 if (rec is EOFRecord)
                 {
                     // A workbook stream is never empty, so crash instead
                     // of trying to keep track of nesting level
                     throw new InvalidOperationException("Nothing between BOF and EOF");
                 }
             }
         }
     }
     else
     {
         // Invalid in a normal workbook stream.
         // However, some test cases work on sub-sections of
         // the workbook stream that do not begin with BOF
         _hasBOFRecord = false;
     }
     _InitialRecordsSize = recSize;
     _filePassRec = fpr;
     _lastRecord = rec;
 }
开发者ID:ctddjyds,项目名称:npoi,代码行数:47,代码来源:RecordFactoryInputStream.cs

示例5: ConvertToInputStream

 private static RecordInputStream ConvertToInputStream(DrawingRecord r)
 {
     byte[] data = r.Serialize();
     RecordInputStream rinp = new RecordInputStream(
             new MemoryStream(data)
     );
     rinp.NextRecord();
     return rinp;
 }
开发者ID:uwitec,项目名称:web-mvc-logistics,代码行数:9,代码来源:DrawingRecordForBiffViewer.cs

示例6: CreateSSTFromRawData

 /**
  * @param rawData serialization of one {@link SSTRecord} and zero or more {@link ContinueRecord}s
  */
 private static SSTRecord CreateSSTFromRawData(byte[] rawData)
 {
     RecordInputStream in1 = new RecordInputStream(new MemoryStream(rawData));
     in1.NextRecord();
     SSTRecord result = new SSTRecord(in1);
     Assert.AreEqual(0, in1.Remaining);
     Assert.IsTrue(!in1.HasNextRecord);
     return result;
 }
开发者ID:hanwangkun,项目名称:npoi,代码行数:12,代码来源:TestSSTRecord.cs

示例7: TestCreate

        public void TestCreate()
        {
            EmbeddedObjectRefSubRecord record1 = new EmbeddedObjectRefSubRecord();

            byte[] ser = record1.Serialize();
            RecordInputStream in2 = new RecordInputStream(new MemoryStream(ser));
            in2.NextRecord();
            EmbeddedObjectRefSubRecord record2 = new EmbeddedObjectRefSubRecord(in2, ser.Length - 4);

            Assert.AreEqual(record1.OLEClassName, record2.OLEClassName);
            Assert.AreEqual(record1.StreamId, record2.StreamId);

            byte[] ser2 = record1.Serialize();
            Assert.IsTrue(Arrays.Equals(ser, ser2));

        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:16,代码来源:TestEmbeddedObjectRefSubRecord.cs

示例8: ExtSSTRecord

        /**
         * Constructs a EOFRecord record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */

        public ExtSSTRecord(RecordInputStream in1)
        {
            field_1_strings_per_bucket = in1.ReadShort();

            int nInfos = in1.Remaining / InfoSubRecord.ENCODED_SIZE;
            List<InfoSubRecord> lst = new List<InfoSubRecord>(nInfos);

            while (in1.Available() > 0)
            {
                InfoSubRecord info = new InfoSubRecord(in1);
                lst.Add(info);

                if (in1.Available() == 0 && in1.HasNextRecord && in1.GetNextSid() == ContinueRecord.sid)
                {
                    in1.NextRecord();
                }
            }
            _sstInfos = lst.ToArray();
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:24,代码来源:ExtSSTRecord.cs

示例9: TestLinkFormula

        public void TestLinkFormula()
        {
            RecordInputStream is1 = new RecordInputStream(new MemoryStream(linkData));
            is1.NextRecord();
            TextObjectRecord rec = new TextObjectRecord(is1);

            Ptg ptg = rec.LinkRefPtg;
            Assert.IsNotNull(ptg);
            Assert.AreEqual(typeof(RefPtg), ptg.GetType());
            RefPtg rptg = (RefPtg)ptg;
            Assert.AreEqual("T2", rptg.ToFormulaString());

            byte[] data2 = rec.Serialize();
            Assert.AreEqual(linkData.Length, data2.Length);
            Assert.IsTrue(Arrays.Equals(linkData, data2));
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:16,代码来源:TestTextObjectRecord.cs

示例10: TestLongRecords

        public void TestLongRecords()
        {
            int[] length = { 1024, 2048, 4096, 8192, 16384 }; //test against strings of different length
            for (int i = 0; i < length.Length; i++)
            {
                StringBuilder buff = new StringBuilder(length[i]);
                for (int j = 0; j < length[i]; j++)
                {
                    buff.Append("x");
                }
                IRichTextString str = new HSSFRichTextString(buff.ToString());

                TextObjectRecord obj = new TextObjectRecord();
                obj.Str = (/*setter*/str);

                byte[] data = obj.Serialize();
                RecordInputStream is1 = new RecordInputStream(new MemoryStream(data));
                is1.NextRecord();
                TextObjectRecord record = new TextObjectRecord(is1);
                str = record.Str;

                Assert.AreEqual(buff.Length, str.Length);
                Assert.AreEqual(buff.ToString(), str.String);
            }
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:25,代码来源:TestTextObjectRecord.cs

示例11: ProcessRecords

        /**
         * Create an array of records from an input stream
         *
         * @param in the InputStream from which the records will be
         *           obtained
         *
         * @exception RecordFormatException on error Processing the
         *            InputStream
         */
        public void ProcessRecords(Stream in1)
        {
            Record last_record = null;

            RecordInputStream recStream = new RecordInputStream(in1);

            while (recStream.HasNextRecord) {
                recStream.NextRecord();
                Record[] recs = RecordFactory.CreateRecord(recStream);   // handle MulRK records
                if (recs.Length > 1) {
                    for (int k = 0; k < recs.Length; k++) {
                        if ( last_record != null ) {
                            if (!ProcessRecord(last_record)) {
                                return;   
                            }
                        }
                        last_record = recs[ k ]; // do to keep the algorithm homogeneous...you can't
                    }                            // actually continue a number record anyhow.
                } else {
                    Record record = recs[ 0 ];

                    if (record != null) {
                        if (last_record != null) {
                            if (!ProcessRecord(last_record)) {
                                return;   
                            }
                        }
                         last_record = record;
                    }
                }
            }
                
            if (last_record != null) {
        	    ProcessRecord(last_record);               
            }
        }
开发者ID:uwitec,项目名称:web-mvc-logistics,代码行数:45,代码来源:EventRecordFactory.cs

示例12: CloneViaReserialise

        /**
 * Clone the current record, via a call to serialise
 *  it, and another to Create a new record from the
 *  bytes.
 * May only be used for classes which don't have
 *  internal counts / ids in them. For those which
 *  do, a full record-aware serialise is needed, which
 *  allocates new ids / counts as needed.
 */
        public override Record CloneViaReserialise()
        {
            // Do it via a re-serialise
            // It's a cheat, but it works...
            byte[] b = this.Serialize();
            RecordInputStream rinp = new RecordInputStream(
                    new System.IO.MemoryStream(b)
            );
            rinp.NextRecord();

            Record[] r = RecordFactory.CreateRecord(rinp);
            if (r.Length != 1)
            {
                throw new InvalidOperationException("Re-serialised a record to Clone it, but got " + r.Length + " records back!");
            }
            return r[0];
        }
开发者ID:uwitec,项目名称:web-mvc-logistics,代码行数:26,代码来源:AbstractEscherHolderRecord.cs

示例13: TextObjectRecord

        public TextObjectRecord(RecordInputStream in1)
        {

            field_1_options = in1.ReadUShort();
            field_2_textOrientation = in1.ReadUShort();
            field_3_reserved4 = in1.ReadUShort();
            field_4_reserved5 = in1.ReadUShort();
            field_5_reserved6 = in1.ReadUShort();
            int field_6_textLength = in1.ReadUShort();
            int field_7_formattingDataLength = in1.ReadUShort();
            field_8_reserved7 = in1.ReadInt();

            if (in1.Remaining > 0)
            {
                // Text Objects can have simple reference formulas
                // (This bit not mentioned in the MS document)
                if (in1.Remaining < 11)
                {
                    throw new RecordFormatException("Not enough remaining data for a link formula");
                }
                int formulaSize = in1.ReadUShort();
                _unknownPreFormulaInt = in1.ReadInt();
                Ptg[] ptgs = Ptg.ReadTokens(formulaSize, in1);
                if (ptgs.Length != 1)
                {
                    throw new RecordFormatException("Read " + ptgs.Length
                            + " tokens but expected exactly 1");
                }
                _linkRefPtg = ptgs[0];
                if (in1.Remaining > 0)
                {
                    _unknownPostFormulaByte = (byte)in1.ReadByte();
                }
                else
                {
                    _unknownPostFormulaByte = null;
                }
            }
            else
            {
                _linkRefPtg = null;
            }
            if (in1.Remaining > 0)
            {
                throw new RecordFormatException("Unused " + in1.Remaining + " bytes at end of record");
            }

            String text;
            if (field_6_textLength > 0)
            {
                text = ReadRawString(in1, field_6_textLength);
            }
            else
            {
                text = "";
            }
            _text = new HSSFRichTextString(text);

            if (field_7_formattingDataLength > 0)
            {
                if (in1.IsContinueNext && in1.Remaining == 0)
                {
                    in1.NextRecord();
                    ProcessFontRuns(in1, _text, field_7_formattingDataLength);
                }
                else
                {
                    throw new RecordFormatException(
                            "Expected Continue Record to hold font runs for TextObjectRecord");
                }
            }
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:72,代码来源:TextObjectRecord.cs

示例14: TestHugeStrings

        public void TestHugeStrings()
        {
            SSTRecord record = new SSTRecord();
            byte[][] bstrings =
                {
                    new byte[9000], new byte[7433], new byte[9002],
                    new byte[16998]
                };
            UnicodeString[] strings = new UnicodeString[bstrings.Length];
            int total_length = 0;

            for (int k = 0; k < bstrings.Length; k++)
            {
                Arrays.Fill(bstrings[k], (byte)('a' + k));
                strings[k] = new UnicodeString(new String(ConvertByteToChar(bstrings[k])));
                record.AddString(strings[k]);
                total_length += 3 + bstrings[k].Length;
            }

            // add overhead of SST record
            total_length += 8;

            // add overhead of broken strings
            total_length += 4;

            // add overhead of six records
            total_length += (6 * 4);
            byte[] content = new byte[record.RecordSize];

            record.Serialize(0, content);
            Assert.AreEqual(total_length, content.Length);

            //Deserialize the record.
            RecordInputStream recStream = new RecordInputStream(new MemoryStream(content));
            recStream.NextRecord();
            record = new SSTRecord(recStream);

            Assert.AreEqual(strings.Length, record.NumStrings);
            Assert.AreEqual(strings.Length, record.NumUniqueStrings);
            Assert.AreEqual(strings.Length, record.CountStrings);
            for (int k = 0; k < strings.Length; k++)
            {
                Assert.AreEqual(strings[k], record.GetString(k));
            }
            record = new SSTRecord();
            bstrings[1] = new byte[bstrings[1].Length - 1];
            for (int k = 0; k < bstrings.Length; k++)
            {
                if ((bstrings[k].Length % 2) == 1)
                {
                    Arrays.Fill(bstrings[k], (byte)('a' + k));
                    strings[k] = new UnicodeString(new String(ConvertByteToChar(bstrings[k])));
                }
                else
                {
                    char[] data = new char[bstrings[k].Length / 2];

                    Arrays.Fill(data, (char)('\u2122' + k));
                    strings[k] = new UnicodeString(new String(data));
                }
                record.AddString(strings[k]);
            }
            content = new byte[record.RecordSize];
            record.Serialize(0, content);
            total_length--;
            Assert.AreEqual(total_length, content.Length);

            recStream = new RecordInputStream(new MemoryStream(content));
            recStream.NextRecord();
            record = new SSTRecord(recStream);

            Assert.AreEqual(strings.Length, record.NumStrings);
            Assert.AreEqual(strings.Length, record.NumUniqueStrings);
            Assert.AreEqual(strings.Length, record.CountStrings);
            for (int k = 0; k < strings.Length; k++)
            {
                Assert.AreEqual(strings[k], record.GetString(k));
            }
        }
开发者ID:hanwangkun,项目名称:npoi,代码行数:79,代码来源:TestSSTRecord.cs

示例15: Create

        /// <summary>
        ///First 4 bytes of data are assumed to be record identifier and length. The supplied 
	    ///data can contain multiple records (sequentially encoded in the same way) 
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
	    public static RecordInputStream Create(byte[] data) {
		    Stream inputStream = new MemoryStream(data);
		    RecordInputStream result = new RecordInputStream(inputStream);
		    result.NextRecord();
		    return result;
	    }
开发者ID:89sos98,项目名称:npoi,代码行数:12,代码来源:TestcaseRecordInputStream.cs


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