本文整理汇总了C#中NPOI.HSSF.Record.ObjRecord.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# ObjRecord.Serialize方法的具体用法?C# ObjRecord.Serialize怎么用?C# ObjRecord.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPOI.HSSF.Record.ObjRecord
的用法示例。
在下文中一共展示了ObjRecord.Serialize方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_47701
public void Test_47701()
{
byte[] data = HexRead.ReadFromString(
"15, 00, 12, 00, 12, 00, 02, 00, 11, 20, " +
"00, 00, 00, 00, 80, 3D, 03, 05, 00, 00, " +
"00, 00, 0C, 00, 14, 00, 00, 00, 00, 00, " +
"00, 00, 00, 00, 00, 00, 01, 00, 0A, 00, " +
"00, 00, 10, 00, 01, 00, 13, 00, EE, 1F, " +
"10, 00, 09, 00, 40, 9F, 74, 01, 25, 09, " +
"00, 0C, 00, 07, 00, 07, 00, 07, 04, 00, " +
"00, 00, 08, 00, 00, 00");
RecordInputStream in1 = TestcaseRecordInputStream.Create(ObjRecord.sid, data);
// check read OK
ObjRecord record = new ObjRecord(in1);
Assert.AreEqual(3, record.SubRecords.Count);
SubRecord sr = record.SubRecords[(2)];
Assert.IsTrue(sr is LbsDataSubRecord);
LbsDataSubRecord lbs = (LbsDataSubRecord)sr;
Assert.AreEqual(4, lbs.NumberOfItems);
Assert.IsTrue(lbs.Formula is AreaPtg);
AreaPtg ptg = (AreaPtg)lbs.Formula;
CellRangeAddress range = new CellRangeAddress(
ptg.FirstRow, ptg.LastRow, ptg.FirstColumn, ptg.LastColumn);
Assert.AreEqual("H10:H13", range.FormatAsString());
// check that it re-Serializes to the same data
byte[] ser = record.Serialize();
TestcaseRecordInputStream.ConfirmRecordEncoding(ObjRecord.sid, data, ser);
}
示例2: TestStore
public void TestStore()
{
ObjRecord record = new ObjRecord(TestcaseRecordInputStream.Create(ObjRecord.sid, recdata));
byte[] recordBytes = record.Serialize();
Assert.AreEqual(26, recordBytes.Length - 4);
byte[] subData = new byte[recdata.Length];
System.Array.Copy(recordBytes, 4, subData, 0, subData.Length);
Assert.IsTrue(NPOI.Util.Arrays.Equals(recdata, subData));
}
示例3: TestReadAll_bug45778
public void TestReadAll_bug45778()
{
RecordInputStream in1 = TestcaseRecordInputStream.Create(dataAutoFilter);
ObjRecord or = new ObjRecord(in1);
byte[] data2 = or.Serialize();
if (data2.Length == 8228)
{
throw new AssertionException("Identified bug 45778");
}
Assert.AreEqual(74, data2.Length);
Assert.IsTrue(Arrays.Equals(dataAutoFilter, data2));
}
示例4: Test_45778
public void Test_45778()
{
byte[] data = HexRead.ReadFromString(
"15, 00, 12, 00, 14, 00, 01, 00, 01, 00, " +
"01, 21, 00, 00, 3C, 13, F4, 03, 00, 00, " +
"00, 00, 0C, 00, 14, 00, 00, 00, 00, 00, " +
"00, 00, 00, 00, 00, 00, 01, 00, 08, 00, 00, " +
"00, 10, 00, 00, 00, " +
"13, 00, EE, 1F, " +
"00, 00, " +
"08, 00, " + //number of items
"08, 00, " + //selected item
"01, 03, " + //flags
"00, 00, " + //objId
//LbsDropData
"0A, 00, " + //flags
"14, 00, " + //the number of lines to be displayed in the dropdown
"6C, 00, " + //the smallest width in pixels allowed for the dropdown window
"00, 00, " + //num chars
"00, 00");
RecordInputStream in1 = TestcaseRecordInputStream.Create(ObjRecord.sid, data);
// check read OK
ObjRecord record = new ObjRecord(in1);
SubRecord sr = record.SubRecords[(2)];
Assert.IsTrue(sr is LbsDataSubRecord);
LbsDataSubRecord lbs = (LbsDataSubRecord)sr;
Assert.AreEqual(8, lbs.NumberOfItems);
Assert.IsNull(lbs.Formula);
// check that it re-Serializes to the same data
byte[] ser = record.Serialize();
TestcaseRecordInputStream.ConfirmRecordEncoding(ObjRecord.sid, data, ser);
}
示例5: Test_Remove_padding
public void Test_Remove_padding()
{
byte[] data = HexRead.ReadFromString(
"5D, 00, 4C, 00, " +
"15, 00, 12, 00, 12, 00, 01, 00, 11, 00, " +
"00, 00, 00, 00, 00, 00, 00, 00, 00, 00, " +
"00, 00, 0C, 00, 14, 00, 00, 00, 00, 00, " +
"00, 00, 00, 00, 00, 00, 01, 00, 09, 00, " +
"00, 00, 0F, 00, 01, 00, " +
"13, 00, 1B, 00, " +
"10, 00, " + //next 16 bytes is a ptg aray
"09, 00, 00, 00, 00, 00, 25, 09, 00, 0C, 00, 07, 00, 07, 00, 00, " +
"01, 00, " + //num lines
"00, 00, " + //selected
"08, 00, " +
"00, 00, " +
"00, 00, 00, 00, 00"); //pAdding bytes
RecordInputStream in1 = TestcaseRecordInputStream.Create(data);
// check read OK
ObjRecord record = new ObjRecord(in1);
// check that it re-Serializes to the same data
byte[] ser = record.Serialize();
Assert.AreEqual(data.Length - 5, ser.Length);
for (int i = 0; i < ser.Length; i++) Assert.AreEqual(data[i], ser[i]);
//check we can read the Trimmed record
RecordInputStream in2 = TestcaseRecordInputStream.Create(ser);
ObjRecord record2 = new ObjRecord(in2);
byte[] ser2 = record2.Serialize();
Assert.IsTrue(Arrays.Equals(ser, ser2));
}
示例6: TestConstruct
public void TestConstruct()
{
ObjRecord record = new ObjRecord();
CommonObjectDataSubRecord ftCmo = new CommonObjectDataSubRecord();
ftCmo.ObjectType = (CommonObjectType.COMMENT);
ftCmo.ObjectId = ((short)1024);
ftCmo.IsLocked = (true);
ftCmo.IsPrintable = (true);
ftCmo.IsAutoFill = (true);
ftCmo.IsAutoline = (true);
record.AddSubRecord(ftCmo);
EndSubRecord ftEnd = new EndSubRecord();
record.AddSubRecord(ftEnd);
//Serialize and Read again
byte[] recordBytes = record.Serialize();
//cut off the record header
byte[] bytes = new byte[recordBytes.Length - 4];
System.Array.Copy(recordBytes, 4, bytes, 0, bytes.Length);
record = new ObjRecord(TestcaseRecordInputStream.Create(ObjRecord.sid, bytes));
IList subrecords = record.SubRecords;
Assert.AreEqual(2, subrecords.Count);
Assert.IsTrue(subrecords[0] is CommonObjectDataSubRecord);
Assert.IsTrue(subrecords[1] is EndSubRecord);
}
示例7: Test4BytePadding
public void Test4BytePadding()
{
// actual data from file saved by Excel 2007
byte[] data = HexRead.ReadFromString(""
+ "15 00 12 00 1E 00 01 00 11 60 B4 6D 3C 01 C4 06 "
+ "49 06 00 00 00 00 00 00 00 00 00 00");
// this data seems to have 2 extra bytes of padding more than usual
// the total may have been padded to the nearest quad-byte length
RecordInputStream in1 = TestcaseRecordInputStream.Create(ObjRecord.sid, data);
// check read OK
ObjRecord record = new ObjRecord(in1);
// check that it re-serializes to the same data
byte[] ser = record.Serialize();
TestcaseRecordInputStream.ConfirmRecordEncoding(ObjRecord.sid, data, ser);
}
示例8: TestReadManualComboWithFormula
public void TestReadManualComboWithFormula()
{
byte[] data = HexRead.ReadFromString(""
+ "5D 00 66 00 "
+ "15 00 12 00 14 00 02 00 11 20 00 00 00 00 "
+ "20 44 C6 04 00 00 00 00 0C 00 14 00 04 F0 C6 04 "
+ "00 00 00 00 00 00 01 00 06 00 00 00 10 00 00 00 "
+ "0E 00 0C 00 05 00 80 44 C6 04 24 09 00 02 00 02 "
+ "13 00 DE 1F 10 00 09 00 80 44 C6 04 25 0A 00 0F "
+ "00 02 00 02 00 02 06 00 03 00 08 00 00 00 00 00 "
+ "08 00 00 00 00 00 00 00 " // TODO sometimes last byte is non-zero
);
RecordInputStream in1 = TestcaseRecordInputStream.Create(data);
ObjRecord or = new ObjRecord(in1);
byte[] data2 = or.Serialize();
if (data2.Length == 8228)
{
throw new AssertionException("Identified bug 45778");
}
Assert.AreEqual(data.Length, data2.Length, "Encoded length");
for (int i = 0; i < data.Length; i++)
{
if (data[i] != data2[i])
{
throw new AssertionException("Encoded data differs at index " + i);
}
}
Assert.IsTrue(Arrays.Equals(data, data2));
}
示例9: TestWayTooMuchPAdding_bug46545
public void TestWayTooMuchPAdding_bug46545()
{
byte[] data = HexRead.ReadFromString(""
+ "15 00 12 00 14 00 13 00 01 21 00 00 00"
+ "00 98 0B 5B 09 00 00 00 00 0C 00 14 00 00 00 00 00 00 00 00"
+ "00 00 00 01 00 01 00 00 00 10 00 00 00 "
// ftLbs
+ "13 00 EE 1F 00 00 "
+ "01 00 00 00 01 06 00 00 02 00 08 00 75 00 "
// ftEnd
+ "00 00 00 00"
);
int LBS_START_POS = 0x002E;
int WRONG_LBS_SIZE = 0x1FEE;
Assert.AreEqual(0x0013, LittleEndian.GetShort(data, LBS_START_POS + 0));
Assert.AreEqual(WRONG_LBS_SIZE, LittleEndian.GetShort(data, LBS_START_POS + 2));
int wrongTotalSize = LBS_START_POS + 4 + WRONG_LBS_SIZE;
byte[] wrongData = new byte[wrongTotalSize];
Array.Copy(data, 0, wrongData, 0, data.Length);
// wrongData has the ObjRecord data as would have been written by v3.1
RecordInputStream in1 = TestcaseRecordInputStream.Create(ObjRecord.sid, wrongData);
ObjRecord or;
try
{
or = new ObjRecord(in1);
}
catch (RecordFormatException e)
{
if (e.Message.StartsWith("Leftover 8154 bytes in subrecord data"))
{
throw new AssertionException("Identified bug 46545");
}
throw e;
}
// make sure POI properly tRuncates the ObjRecord data
byte[] data2 = or.Serialize();
TestcaseRecordInputStream.ConfirmRecordEncoding(ObjRecord.sid, data, data2);
}