private static void DrawLinesToCenter(HSSFPatriarch patriarch) { // Draw some lines from and to the corners { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.SetAnchor((short)2, 2, 0, 0, (short)2, 2, 512, 128); HSSFSimpleShape shape1 = patriarch.CreateSimpleShape(a1); shape1.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_LINE); } { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.SetAnchor((short)2, 2, 512, 128, (short)2, 2, 1023, 0); HSSFSimpleShape shape1 = patriarch.CreateSimpleShape(a1); shape1.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_LINE); } { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.SetAnchor((short)1, 1, 0, 0, (short)1, 1, 512, 100); HSSFSimpleShape shape1 = patriarch.CreateSimpleShape(a1); shape1.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_LINE); } { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.SetAnchor((short)1, 1, 512, 100, (short)1, 1, 1023, 0); HSSFSimpleShape shape1 = patriarch.CreateSimpleShape(a1); shape1.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_LINE); } }
public void TestBug45312() { HSSFWorkbook wb = new HSSFWorkbook(); try { HSSFSheet sheet = wb.CreateSheet() as HSSFSheet; HSSFPatriarch patriarch = sheet.CreateDrawingPatriarch() as HSSFPatriarch; { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.SetAnchor((short)1, 1, 0, 0, (short)1, 1, 512, 100); HSSFSimpleShape shape1 = patriarch.CreateSimpleShape(a1); shape1.ShapeType = (/*setter*/HSSFSimpleShape.OBJECT_TYPE_LINE); } { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.SetAnchor((short)1, 1, 512, 0, (short)1, 1, 1024, 100); HSSFSimpleShape shape1 = patriarch.CreateSimpleShape(a1); shape1.FlipVertical=(true); shape1.ShapeType = (/*setter*/HSSFSimpleShape.OBJECT_TYPE_LINE); } { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.SetAnchor((short)2, 2, 0, 0, (short)2, 2, 512, 100); HSSFSimpleShape shape1 = patriarch.CreateSimpleShape(a1); shape1.ShapeType = (/*setter*/HSSFSimpleShape.OBJECT_TYPE_LINE); } { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.SetAnchor((short)2, 2, 0, 100, (short)2, 2, 512, 200); HSSFSimpleShape shape1 = patriarch.CreateSimpleShape(a1); shape1.FlipHorizontal = (/*setter*/true); shape1.ShapeType = (/*setter*/HSSFSimpleShape.OBJECT_TYPE_LINE); } /*OutputStream stream = new FileOutputStream("/tmp/45312.xls"); try { wb.Write(stream); } finally { stream.Close(); }*/ CheckWorkbookBack(wb); } finally { //wb.Close(); } }
private static void DrawGrid(HSSFPatriarch patriarch) { // This Draws a grid of lines. Since the coordinates space fixed at // 1024 by 256 we use a ratio to get a reasonably square grids. double xRatio = 3.22; double yRatio = 0.6711; int x1 = 000; int y1 = 000; int x2 = 000; int y2 = 200; for (int i = 0; i < 20; i++) { HSSFClientAnchor a2 = new HSSFClientAnchor(); a2.SetAnchor((short)2, 2, (int)(x1 * xRatio), (int)(y1 * yRatio), (short)2, 2, (int)(x2 * xRatio), (int)(y2 * yRatio)); HSSFSimpleShape shape2 = patriarch.CreateSimpleShape(a2); shape2.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_LINE); x1 += 10; x2 += 10; } x1 = 000; y1 = 000; x2 = 200; y2 = 000; for (int i = 0; i < 20; i++) { HSSFClientAnchor a2 = new HSSFClientAnchor(); a2.SetAnchor((short)2, 2, (int)(x1 * xRatio), (int)(y1 * yRatio), (short)2, 2, (int)(x2 * xRatio), (int)(y2 * yRatio)); HSSFSimpleShape shape2 = patriarch.CreateSimpleShape(a2); shape2.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_LINE); y1 += 10; y2 += 10; } }
private static void DrawManyLines(HSSFPatriarch patriarch) { // Draw bunch of lines int x1 = 100; int y1 = 100; int x2 = 800; int y2 = 200; int color = 0; for (int i = 0; i < 10; i++) { HSSFClientAnchor a2 = new HSSFClientAnchor(); a2.SetAnchor((short)2, 2, x1, y1, (short)2, 2, x2, y2); HSSFSimpleShape shape2 = patriarch.CreateSimpleShape(a2); shape2.ShapeType = HSSFSimpleShape.OBJECT_TYPE_LINE; shape2.LineStyleColor = color; y1 -= 10; y2 -= 10; color += 30; } }
private static void DrawPolygon(HSSFPatriarch patriarch) { HSSFClientAnchor a = new HSSFClientAnchor(); a.SetAnchor((short)2, 2, 0, 0, (short)3, 3, 1023, 255); HSSFShapeGroup g = patriarch.CreateGroup(a); g.SetCoordinates(0, 0, 200, 200); HSSFPolygon p1 = g.CreatePolygon(new HSSFChildAnchor(0, 0, 200, 200)); p1.SetPolygonDrawArea(100, 100); p1.SetPoints(new int[] { 0, 90, 50 }, new int[] { 5, 5, 44 }); p1.SetFillColor(0, 255, 0); HSSFPolygon p2 = g.CreatePolygon(new HSSFChildAnchor(20, 20, 200, 200)); p2.SetPolygonDrawArea(200, 200); p2.SetPoints(new int[] { 120, 20, 150 }, new int[] { 105, 30, 195 }); p2.SetFillColor(255, 0, 0); }
private static void DrawOval(HSSFPatriarch patriarch) { // Create an oval and style to taste. HSSFClientAnchor a = new HSSFClientAnchor(); a.SetAnchor((short)2, 2, 20, 20, (short)2, 2, 190, 80); HSSFSimpleShape s = patriarch.CreateSimpleShape(a); s.ShapeType = HSSFSimpleShape.OBJECT_TYPE_OVAL; s.SetLineStyleColor(10, 10, 10); s.SetFillColor(90, 10, 200); s.LineWidth = HSSFShape.LINEWIDTH_ONE_PT * 3; s.LineStyle = LineStyle.DotSys; }
public void TestClientAnchorFromScratch() { HSSFClientAnchor anchor = new HSSFClientAnchor(); EscherClientAnchorRecord escher = (EscherClientAnchorRecord)HSSFTestHelper.GetEscherAnchor(anchor); anchor.SetAnchor((short)11, 12, 13, 14, (short)15, 16, 17, 18); Assert.AreEqual(anchor.Col1, 11); Assert.AreEqual(escher.Col1, 11); Assert.AreEqual(anchor.Col2, 15); Assert.AreEqual(escher.Col2, 15); Assert.AreEqual(anchor.Row1, 12); Assert.AreEqual(escher.Row1, 12); Assert.AreEqual(anchor.Row2, 16); Assert.AreEqual(escher.Row2, 16); Assert.AreEqual(anchor.Dx1, 13); Assert.AreEqual(escher.Dx1, 13); Assert.AreEqual(anchor.Dx2, 17); Assert.AreEqual(escher.Dx2, 17); Assert.AreEqual(anchor.Dy1, 14); Assert.AreEqual(escher.Dy1, 14); Assert.AreEqual(anchor.Dy2, 18); Assert.AreEqual(escher.Dy2, 18); anchor.Col1=(111); Assert.AreEqual(anchor.Col1, 111); Assert.AreEqual(escher.Col1, 111); anchor.Col2=(112); Assert.AreEqual(anchor.Col2, 112); Assert.AreEqual(escher.Col2, 112); anchor.Row1=(113); Assert.AreEqual(anchor.Row1, 113); Assert.AreEqual(escher.Row1, 113); anchor.Row2=(114); Assert.AreEqual(anchor.Row2, 114); Assert.AreEqual(escher.Row2, 114); anchor.Dx1=(115); Assert.AreEqual(anchor.Dx1, 115); Assert.AreEqual(escher.Dx1, 115); anchor.Dx2=(116); Assert.AreEqual(anchor.Dx2, 116); Assert.AreEqual(escher.Dx2, 116); anchor.Dy1=(117); Assert.AreEqual(anchor.Dy1, 117); Assert.AreEqual(escher.Dy1, 117); anchor.Dy2=(118); Assert.AreEqual(anchor.Dy2, 118); Assert.AreEqual(escher.Dy2, 118); }