public void TestBSEPictureRef() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sh = wb.CreateSheet("Pictures") as HSSFSheet; HSSFPatriarch dr = sh.CreateDrawingPatriarch() as HSSFPatriarch; HSSFClientAnchor anchor = new HSSFClientAnchor(); InternalSheet ish = HSSFTestHelper.GetSheetForTest(sh); //register a picture byte[] data1 = new byte[] { 1, 2, 3 }; int idx1 = wb.AddPicture(data1, PictureType.JPEG); Assert.AreEqual(1, idx1); HSSFPicture p1 = dr.CreatePicture(anchor, idx1) as HSSFPicture; EscherBSERecord bse = wb.Workbook.GetBSERecord(idx1); Assert.AreEqual(bse.Ref, 1); dr.CreatePicture(new HSSFClientAnchor(), idx1); Assert.AreEqual(bse.Ref, 2); HSSFShapeGroup gr = dr.CreateGroup(new HSSFClientAnchor()); gr.CreatePicture(new HSSFChildAnchor(), idx1); Assert.AreEqual(bse.Ref, 3); }
public void TestClearShapes() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.CreateSheet() as HSSFSheet; HSSFPatriarch patriarch = sheet.CreateDrawingPatriarch() as HSSFPatriarch; HSSFShapeGroup group = patriarch.CreateGroup(new HSSFClientAnchor()); group.CreateShape(new HSSFChildAnchor()); group.CreateShape(new HSSFChildAnchor()); EscherAggregate agg = HSSFTestHelper.GetEscherAggregate(patriarch); Assert.AreEqual(agg.GetShapeToObjMapping().Count, 5); Assert.AreEqual(agg.TailRecords.Count, 0); Assert.AreEqual(group.Children.Count, 2); group.Clear(); Assert.AreEqual(agg.GetShapeToObjMapping().Count, 1); Assert.AreEqual(agg.TailRecords.Count, 0); Assert.AreEqual(group.Children.Count, 0); wb = HSSFTestDataSamples.WriteOutAndReadBack(wb); sheet = wb.GetSheetAt(0) as HSSFSheet; patriarch = sheet.DrawingPatriarch as HSSFPatriarch; group = (HSSFShapeGroup)patriarch.Children[(0)]; Assert.AreEqual(agg.GetShapeToObjMapping().Count, 1); Assert.AreEqual(agg.TailRecords.Count, 0); Assert.AreEqual(group.Children.Count, 0); }
public void TestCloneSheetWithoutDrawings() { HSSFWorkbook b = new HSSFWorkbook(); HSSFSheet s = b.CreateSheet("Test") as HSSFSheet; HSSFSheet s2 = s.CloneSheet(b) as HSSFSheet; Assert.IsNull(s.DrawingPatriarch); Assert.IsNull(s2.DrawingPatriarch); Assert.AreEqual(HSSFTestHelper.GetSheetForTest(s).Records.Count, HSSFTestHelper.GetSheetForTest(s2).Records.Count); }
public void TestInitState() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sh = wb.CreateSheet() as HSSFSheet; HSSFPatriarch patriarch = sh.CreateDrawingPatriarch() as HSSFPatriarch; EscherAggregate agg = HSSFTestHelper.GetEscherAggregate(patriarch); Assert.AreEqual(agg.TailRecords.Count, 0); HSSFComment comment = patriarch.CreateCellComment(new HSSFClientAnchor()) as HSSFComment; Assert.AreEqual(agg.TailRecords.Count, 1); HSSFSimpleShape shape = patriarch.CreateSimpleShape(new HSSFClientAnchor()); Assert.AreEqual(comment.GetOptRecord().EscherProperties.Count, 10); }