public void TestWideRecordLength() { BoundSheetRecord record = new BoundSheetRecord("Sheet\u20ac"); record.Sheetname = ("Sheet\u20ac"); Assert.AreEqual(24, record.RecordSize, " 2 + 2 + 4 + 2 + 1 + 1 + len(str) * 2"); }
/// <summary> /// Creates a stub Workbook from the supplied records, /// suitable for use with the {@link HSSFFormulaParser} /// </summary> /// <param name="externs">The ExternSheetRecords in your file</param> /// <param name="bounds">The BoundSheetRecords in your file</param> /// <param name="sst">TThe SSTRecord in your file.</param> /// <returns>A stub Workbook suitable for use with HSSFFormulaParser</returns> public static InternalWorkbook CreateStubWorkbook(ExternSheetRecord[] externs, BoundSheetRecord[] bounds, SSTRecord sst) { List<Record> wbRecords = new List<Record>(); // Core Workbook records go first if (bounds != null) { for (int i = 0; i < bounds.Length; i++) { wbRecords.Add(bounds[i]); } } if (sst != null) { wbRecords.Add(sst); } // Now we can have the ExternSheetRecords, // preceded by a SupBookRecord if (externs != null) { wbRecords.Add(SupBookRecord.CreateInternalReferences( (short)externs.Length)); for (int i = 0; i < externs.Length; i++) { wbRecords.Add(externs[i]); } } // Finally we need an EoF record wbRecords.Add(EOFRecord.instance); return InternalWorkbook.CreateWorkbook(wbRecords); }
public void TestName() { BoundSheetRecord record = new BoundSheetRecord("1234567890223456789032345678904"); try { record.Sheetname = ("s//*s"); Assert.IsTrue(false, "Should have thrown ArgumentException, but didnt"); } catch (ArgumentException) { } }
public void TestDeSerializeUnicode() { byte[] data = HexRead.ReadFromString("" + "85 00 1A 00" // sid, length + "3C 09 00 00" // bof + "00 00"// flags + "09 01" // str-len. unicode flag // string data + "21 04 42 04 40 04" + "30 04 3D 04 38 04" + "47 04 3A 04 30 04" ); RecordInputStream in1 = TestcaseRecordInputStream.Create(data); BoundSheetRecord bsr = new BoundSheetRecord(in1); // sheet name is unicode Russian for 'minor page' Assert.AreEqual("\u0421\u0442\u0440\u0430\u043D\u0438\u0447\u043A\u0430", bsr.Sheetname); byte[] data2 = bsr.Serialize(); Assert.IsTrue(Arrays.Equals(data, data2)); }
/// <summary> /// Creates a stub workbook from the supplied records, /// suitable for use with the HSSFFormulaParser /// </summary> /// <param name="externs">The ExternSheetRecords in your file</param> /// <param name="bounds">A stub Workbook suitable for use with HSSFFormulaParser</param> /// <returns>A stub Workbook suitable for use with {@link HSSFFormulaParser}</returns> public static InternalWorkbook CreateStubWorkbook(ExternSheetRecord[] externs, BoundSheetRecord[] bounds) { return CreateStubWorkbook(externs, bounds, null); }
public int Compare(BoundSheetRecord bsr1, BoundSheetRecord bsr2) { return(bsr1.PositionOfBof - bsr2.PositionOfBof); }
public int Compare(BoundSheetRecord bsr1, BoundSheetRecord bsr2) { return bsr1.PositionOfBof - bsr2.PositionOfBof; }
public void TestOrdering() { BoundSheetRecord bs1 = new BoundSheetRecord("SheetB"); BoundSheetRecord bs2 = new BoundSheetRecord("SheetC"); BoundSheetRecord bs3 = new BoundSheetRecord("SheetA"); bs1.PositionOfBof = (/*setter*/11); bs2.PositionOfBof = (/*setter*/33); bs3.PositionOfBof = (/*setter*/22); List<BoundSheetRecord> l = new List<BoundSheetRecord>(); l.Add(bs1); l.Add(bs2); l.Add(bs3); BoundSheetRecord[] r = BoundSheetRecord.OrderByBofPosition(l); Assert.AreEqual(3, r.Length); Assert.AreEqual(bs1, r[0]); Assert.AreEqual(bs3, r[1]); Assert.AreEqual(bs2, r[2]); }
public void TestRecordLength() { BoundSheetRecord record = new BoundSheetRecord("Sheet1"); Assert.AreEqual(18, record.RecordSize, " 2 + 2 + 4 + 2 + 1 + 1 + len(str)"); }