public void TestPolygonPoints() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sh = wb.CreateSheet() as HSSFSheet; HSSFPatriarch patriarch = sh.CreateDrawingPatriarch() as HSSFPatriarch; HSSFPolygon polygon = patriarch.CreatePolygon(new HSSFClientAnchor()); polygon.SetPolygonDrawArea(100, 100); polygon.SetPoints(new int[] { 0, 90, 50, 90 }, new int[] { 5, 5, 44, 88 }); PolygonShape polygonShape = HSSFTestModelHelper.CreatePolygonShape(0, polygon); EscherArrayProperty verticesProp1 = polygon.GetOptRecord().Lookup(EscherProperties.GEOMETRY__VERTICES) as EscherArrayProperty; EscherArrayProperty verticesProp2 = ((EscherOptRecord)polygonShape.SpContainer.GetChildById(EscherOptRecord.RECORD_ID)) .Lookup(EscherProperties.GEOMETRY__VERTICES) as EscherArrayProperty; Assert.AreEqual(verticesProp1.NumberOfElementsInArray, verticesProp2.NumberOfElementsInArray); Assert.AreEqual(verticesProp1.ToXml(""), verticesProp2.ToXml("")); polygon.SetPoints(new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 }); Assert.IsTrue(Arrays.Equals(polygon.XPoints, new int[] { 1, 2, 3 })); Assert.IsTrue(Arrays.Equals(polygon.YPoints, new int[] { 4, 5, 6 })); polygonShape = HSSFTestModelHelper.CreatePolygonShape(0, polygon); verticesProp1 = polygon.GetOptRecord().Lookup(EscherProperties.GEOMETRY__VERTICES) as EscherArrayProperty; verticesProp2 = ((EscherOptRecord)polygonShape.SpContainer.GetChildById(EscherOptRecord.RECORD_ID)) .Lookup(EscherProperties.GEOMETRY__VERTICES) as EscherArrayProperty; Assert.AreEqual(verticesProp1.NumberOfElementsInArray, verticesProp2.NumberOfElementsInArray); Assert.AreEqual(verticesProp1.ToXml(""), verticesProp2.ToXml("")); }
/** * Create a new Table of the given number of rows and columns * * @param numrows the number of rows * @param numcols the number of columns */ public Table(int numrows, int numcols) { base(); if(numrows < 1) throw new ArgumentException("The number of rows must be greater than 1"); if(numcols < 1) throw new ArgumentException("The number of columns must be greater than 1"); int x=0, y=0, tblWidth=0, tblHeight=0; cells = new TableCell[numrows][numcols]; for (int i = 0; i < cells.Length; i++) { x = 0; for (int j = 0; j < cells[i].Length; j++) { cells[i][j] = new TableCell(this); Rectangle anchor = new Rectangle(x, y, TableCell.DEFAULT_WIDTH, TableCell.DEFAULT_HEIGHT); cells[i][j].SetAnchor(anchor); x += TableCell.DEFAULT_WIDTH; } y += TableCell.DEFAULT_HEIGHT; } tblWidth = x; tblHeight = y; SetAnchor(new Rectangle(0, 0, tblWidth, tblHeight)); EscherContainerRecord spCont = (EscherContainerRecord) GetSpContainer().GetChild(0); EscherOptRecord opt = new EscherOptRecord(); opt.SetRecordId((short)0xF122); opt.AddEscherProperty(new EscherSimpleProperty((short)0x39F, 1)); EscherArrayProperty p = new EscherArrayProperty((short)0x43A0, false, null); p.SetSizeOfElements(0x0004); p.SetNumberOfElementsInArray(numrows); p.SetNumberOfElementsInMemory(numrows); opt.AddEscherProperty(p); List<EscherRecord> lst = spCont.GetChildRecords(); lst.Add(lst.Count-1, opt); spCont.SetChildRecords(lst); }
/** * Set the polygon vertices * * @param xPoints * @param yPoints */ public void SetPoints(float[] xPoints, float[] yPoints) { float right = FindBiggest(xPoints); float bottom = FindBiggest(yPoints); float left = FindSmallest(xPoints); float top = FindSmallest(yPoints); EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, (int)((right - left)*POINT_DPI/MASTER_DPI))); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, (int)((bottom - top)*POINT_DPI/MASTER_DPI))); for (int i = 0; i < xPoints.Length; i++) { xPoints[i] += -left; yPoints[i] += -top; } int numpoints = xPoints.Length; EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0] ); verticesProp.SetNumberOfElementsInArray(numpoints+1); verticesProp.SetNumberOfElementsInMemory(numpoints+1); verticesProp.SetSizeOfElements(0xFFF0); for (int i = 0; i < numpoints; i++) { byte[] data = new byte[4]; LittleEndian.Putshort(data, 0, (short)(xPoints[i]*POINT_DPI/MASTER_DPI)); LittleEndian.Putshort(data, 2, (short)(yPoints[i]*POINT_DPI/MASTER_DPI)); verticesProp.SetElement(i, data); } byte[] data = new byte[4]; LittleEndian.Putshort(data, 0, (short)(xPoints[0]*POINT_DPI/MASTER_DPI)); LittleEndian.Putshort(data, 2, (short)(yPoints[0]*POINT_DPI/MASTER_DPI)); verticesProp.SetElement(numpoints, data); opt.AddEscherProperty(verticesProp); EscherArrayProperty segmentsProp = new EscherArrayProperty(EscherProperties.GEOMETRY__SEGMENTINFO, false, null ); segmentsProp.SetSizeOfElements(0x0002); segmentsProp.SetNumberOfElementsInArray(numpoints * 2 + 4); segmentsProp.SetNumberOfElementsInMemory(numpoints * 2 + 4); segmentsProp.SetElement(0, new byte[] { (byte)0x00, (byte)0x40 } ); segmentsProp.SetElement(1, new byte[] { (byte)0x00, (byte)0xAC } ); for (int i = 0; i < numpoints; i++) { segmentsProp.SetElement(2 + i * 2, new byte[] { (byte)0x01, (byte)0x00 } ); segmentsProp.SetElement(3 + i * 2, new byte[] { (byte)0x00, (byte)0xAC } ); } segmentsProp.SetElement(segmentsProp.GetNumberOfElementsInArray() - 2, new byte[] { (byte)0x01, (byte)0x60 } ); segmentsProp.SetElement(segmentsProp.GetNumberOfElementsInArray() - 1, new byte[] { (byte)0x00, (byte)0x80 } ); opt.AddEscherProperty(segmentsProp); opt.sortProperties(); }
/** * @param xPoints - array of x coordinates * @param yPoints - array of y coordinates */ public void SetPoints(int[] xPoints, int[] yPoints) { if (xPoints.Length != yPoints.Length) { logger.Log(POILogger.ERROR, "xPoint.Length must be equal to yPoints.Length"); return; } if (xPoints.Length == 0) { logger.Log(POILogger.ERROR, "HSSFPolygon must have at least one point"); } EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0]); verticesProp.NumberOfElementsInArray = (xPoints.Length + 1); verticesProp.NumberOfElementsInMemory = (xPoints.Length + 1); verticesProp.SizeOfElements = unchecked ((short)(0xFFF0)); byte[] data; for (int i = 0; i < xPoints.Length; i++) { data = new byte[4]; LittleEndian.PutShort(data, 0, (short)xPoints[i]); LittleEndian.PutShort(data, 2, (short)yPoints[i]); verticesProp.SetElement(i, data); } int point = xPoints.Length; data = new byte[4]; LittleEndian.PutShort(data, 0, (short)xPoints[0]); LittleEndian.PutShort(data, 2, (short)yPoints[0]); verticesProp.SetElement(point, data); SetPropertyValue(verticesProp); EscherArrayProperty segmentsProp = new EscherArrayProperty(EscherProperties.GEOMETRY__SEGMENTINFO, false, null); segmentsProp.SizeOfElements = (0x0002); segmentsProp.NumberOfElementsInArray = (xPoints.Length * 2 + 4); segmentsProp.NumberOfElementsInMemory = (xPoints.Length * 2 + 4); segmentsProp.SetElement(0, new byte[] { (byte)0x00, (byte)0x40 }); segmentsProp.SetElement(1, new byte[] { (byte)0x00, (byte)0xAC }); for (int i = 0; i < xPoints.Length; i++) { segmentsProp.SetElement(2 + i * 2, new byte[] { (byte)0x01, (byte)0x00 }); segmentsProp.SetElement(3 + i * 2, new byte[] { (byte)0x00, (byte)0xAC }); } segmentsProp.SetElement(segmentsProp.NumberOfElementsInArray - 2, new byte[] { (byte)0x01, (byte)0x60 }); segmentsProp.SetElement(segmentsProp.NumberOfElementsInArray - 1, new byte[] { (byte)0x00, (byte)0x80 }); SetPropertyValue(segmentsProp); }
public void TestPolygonPoints() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sh = wb.CreateSheet() as HSSFSheet; HSSFPatriarch patriarch = sh.CreateDrawingPatriarch() as HSSFPatriarch; HSSFPolygon polygon = patriarch.CreatePolygon(new HSSFClientAnchor()); polygon.SetPolygonDrawArea(100, 100); polygon.SetPoints(new int[] { 0, 90, 50, 90 }, new int[] { 5, 5, 44, 88 }); EscherArrayProperty verticesProp1 = polygon.GetOptRecord().Lookup(EscherProperties.GEOMETRY__VERTICES) as EscherArrayProperty; String expected = "<EscherArrayProperty id=\"0x8145\" name=\"geometry.vertices\" blipId=\"false\">" + "<Element>[00, 00, 05, 00]</Element>" + "<Element>[5A, 00, 05, 00]</Element>" + "<Element>[32, 00, 2C, 00]</Element>" + "<Element>[5A, 00, 58, 00]</Element>" + "<Element>[00, 00, 05, 00]</Element>" + "</EscherArrayProperty>"; String actual = verticesProp1.ToXml("").Replace("\r", "").Replace("\n", "").Replace("\t", ""); Assert.AreEqual(verticesProp1.NumberOfElementsInArray, 5); Assert.AreEqual(expected, actual); polygon.SetPoints(new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 }); Assert.IsTrue(Arrays.Equals(polygon.XPoints, new int[] { 1, 2, 3 })); Assert.IsTrue(Arrays.Equals(polygon.YPoints, new int[] { 4, 5, 6 })); verticesProp1 = polygon.GetOptRecord().Lookup(EscherProperties.GEOMETRY__VERTICES) as EscherArrayProperty; expected = "<EscherArrayProperty id=\"0x8145\" name=\"geometry.vertices\" blipId=\"false\">" + "<Element>[01, 00, 04, 00]</Element>" + "<Element>[02, 00, 05, 00]</Element>" + "<Element>[03, 00, 06, 00]</Element>" + "<Element>[01, 00, 04, 00]</Element>" + "</EscherArrayProperty>"; actual = verticesProp1.ToXml("").Replace("\r", "").Replace("\n", "").Replace("\t", ""); Assert.AreEqual(verticesProp1.NumberOfElementsInArray, 4); Assert.AreEqual(expected, actual); wb.Close(); }
public void TestEmptyArrayProperty() { EscherOptRecord r = new EscherOptRecord(); EscherArrayProperty p = new EscherArrayProperty(unchecked ((short)(EscherProperties.FILL__SHADECOLORS + 0x8000)), new byte[0]); Assert.AreEqual(0, p.NumberOfElementsInArray); r.AddEscherProperty(p); byte[] data1 = r.Serialize(); EscherOptRecord opt2 = new EscherOptRecord(); opt2.FillFields(data1, new DefaultEscherRecordFactory()); p = (EscherArrayProperty)opt2.EscherProperties[0]; Assert.AreEqual(0, p.NumberOfElementsInArray); byte[] data2 = opt2.Serialize(); Assert.IsTrue(Arrays.Equals(data1, data2)); }
/// <summary> /// Creates the lowerlevel escher records for this shape. /// </summary> /// <param name="hssfShape">The HSSF shape.</param> /// <param name="shapeId">The shape id.</param> /// <returns></returns> private EscherContainerRecord CreateSpContainer(HSSFPolygon hssfShape, int shapeId) { HSSFShape shape = hssfShape; EscherContainerRecord spContainer = new EscherContainerRecord(); EscherSpRecord sp = new EscherSpRecord(); EscherOptRecord opt = new EscherOptRecord(); EscherClientDataRecord clientData = new EscherClientDataRecord(); spContainer.RecordId = EscherContainerRecord.SP_CONTAINER; spContainer.Options = (short)0x000F; sp.RecordId = EscherSpRecord.RECORD_ID; sp.Options = (short)((EscherAggregate.ST_DONUT << 4) | 0x2); sp.ShapeId = shapeId; if (hssfShape.Parent == null) { sp.Flags = EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE; } else { sp.Flags = EscherSpRecord.FLAG_CHILD | EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE; } opt.RecordId = EscherOptRecord.RECORD_ID; opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TRANSFORM__ROTATION, false, false, 0)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, false, false, hssfShape.DrawAreaWidth)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, false, false, hssfShape.DrawAreaHeight)); opt.AddEscherProperty(new EscherShapePathProperty(EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX)); EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0]); verticesProp.NumberOfElementsInArray = (hssfShape.XPoints.Length + 1); verticesProp.NumberOfElementsInMemory = (hssfShape.XPoints.Length + 1); verticesProp.SizeOfElements = unchecked ((short)0xFFF0); for (int i = 0; i < hssfShape.XPoints.Length; i++) { byte[] data = new byte[4]; LittleEndian.PutShort(data, 0, (short)hssfShape.XPoints[i]); LittleEndian.PutShort(data, 2, (short)hssfShape.YPoints[i]); verticesProp.SetElement(i, data); } int point = hssfShape.XPoints.Length; byte[] data1 = new byte[4]; LittleEndian.PutShort(data1, 0, (short)hssfShape.XPoints[0]); LittleEndian.PutShort(data1, 2, (short)hssfShape.YPoints[0]); verticesProp.SetElement(point, data1); opt.AddEscherProperty(verticesProp); EscherArrayProperty segmentsProp = new EscherArrayProperty(EscherProperties.GEOMETRY__SEGMENTINFO, false, null); segmentsProp.SizeOfElements = (0x0002); segmentsProp.NumberOfElementsInArray = (hssfShape.XPoints.Length * 2 + 4); segmentsProp.NumberOfElementsInMemory = (hssfShape.XPoints.Length * 2 + 4); segmentsProp.SetElement(0, new byte[] { (byte)0x00, (byte)0x40 }); segmentsProp.SetElement(1, new byte[] { (byte)0x00, (byte)0xAC }); for (int i = 0; i < hssfShape.XPoints.Length; i++) { segmentsProp.SetElement(2 + i * 2, new byte[] { (byte)0x01, (byte)0x00 }); segmentsProp.SetElement(3 + i * 2, new byte[] { (byte)0x00, (byte)0xAC }); } segmentsProp.SetElement(segmentsProp.NumberOfElementsInArray - 2, new byte[] { (byte)0x01, (byte)0x60 }); segmentsProp.SetElement(segmentsProp.NumberOfElementsInArray - 1, new byte[] { (byte)0x00, (byte)0x80 }); opt.AddEscherProperty(segmentsProp); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__FillOK, false, false, 0x00010001)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINESTARTARROWHEAD, false, false, 0x0)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDARROWHEAD, false, false, 0x0)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, false, false, 0x0)); AddStandardOptions(shape, opt); EscherRecord anchor = CreateAnchor(shape.Anchor); clientData.RecordId = (EscherClientDataRecord.RECORD_ID); clientData.Options = (short)0x0000; spContainer.AddChildRecord(sp); spContainer.AddChildRecord(opt); spContainer.AddChildRecord(anchor); spContainer.AddChildRecord(clientData); return(spContainer); }
/** * Set the shape path * * @param path */ public void SetPath(GeneralPath path) { Rectangle2D bounds = path.GetBounds2D(); PathIterator it = path.GetPathIterator(new AffineTransform()); List<byte[]> segInfo = new List<byte[]>(); List<Point2D.Double> pntInfo = new List<Point2D.Double>(); bool IsClosed = false; while (!it.IsDone()) { double[] vals = new double[6]; int type = it.currentSegment(vals); switch (type) { case PathIterator.SEG_MOVETO: pntInfo.Add(new Point2D.Double(vals[0], vals[1])); segInfo.Add(SEGMENTINFO_MOVETO); break; case PathIterator.SEG_LINETO: pntInfo.Add(new Point2D.Double(vals[0], vals[1])); segInfo.Add(SEGMENTINFO_LINETO); segInfo.Add(SEGMENTINFO_ESCAPE); break; case PathIterator.SEG_CUBICTO: pntInfo.Add(new Point2D.Double(vals[0], vals[1])); pntInfo.Add(new Point2D.Double(vals[2], vals[3])); pntInfo.Add(new Point2D.Double(vals[4], vals[5])); segInfo.Add(SEGMENTINFO_CUBICTO); segInfo.Add(SEGMENTINFO_ESCAPE2); break; case PathIterator.SEG_QUADTO: //TODO: figure out how to convert SEG_QUADTO into SEG_CUBICTO logger.log(POILogger.WARN, "SEG_QUADTO is not supported"); break; case PathIterator.SEG_CLOSE: pntInfo.Add(pntInfo.Get(0)); segInfo.Add(SEGMENTINFO_LINETO); segInfo.Add(SEGMENTINFO_ESCAPE); segInfo.Add(SEGMENTINFO_LINETO); segInfo.Add(SEGMENTINFO_CLOSE); isClosed = true; break; } it.next(); } if(!isClosed) segInfo.Add(SEGMENTINFO_LINETO); segInfo.Add(new byte[]{0x00, (byte)0x80}); EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4)); EscherArrayProperty verticesProp = new EscherArrayProperty((short)(EscherProperties.GEOMETRY__VERTICES + 0x4000), false, null); verticesProp.SetNumberOfElementsInArray(pntInfo.Count); verticesProp.SetNumberOfElementsInMemory(pntInfo.Count); verticesProp.SetSizeOfElements(0xFFF0); for (int i = 0; i < pntInfo.Count; i++) { Point2D.Double pnt = pntInfo.Get(i); byte[] data = new byte[4]; LittleEndian.Putshort(data, 0, (short)((pnt.GetX() - bounds.GetX())*MASTER_DPI/POINT_DPI)); LittleEndian.Putshort(data, 2, (short)((pnt.GetY() - bounds.GetY())*MASTER_DPI/POINT_DPI)); verticesProp.SetElement(i, data); } opt.AddEscherProperty(verticesProp); EscherArrayProperty segmentsProp = new EscherArrayProperty((short)(EscherProperties.GEOMETRY__SEGMENTINFO + 0x4000), false, null); segmentsProp.SetNumberOfElementsInArray(segInfo.Count); segmentsProp.SetNumberOfElementsInMemory(segInfo.Count); segmentsProp.SetSizeOfElements(0x2); for (int i = 0; i < segInfo.Count; i++) { byte[] seg = segInfo.Get(i); segmentsProp.SetElement(i, seg); } opt.AddEscherProperty(segmentsProp); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, (int)(bounds.Width*MASTER_DPI/POINT_DPI))); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, (int)(bounds.Height*MASTER_DPI/POINT_DPI))); opt.sortProperties(); SetAnchor(bounds); }
/// <summary> /// Creates the lowerlevel escher records for this shape. /// </summary> /// <param name="hssfShape">The HSSF shape.</param> /// <param name="shapeId">The shape id.</param> /// <returns></returns> private EscherContainerRecord CreateSpContainer(HSSFPolygon hssfShape, int shapeId) { HSSFShape shape = hssfShape; EscherContainerRecord spContainer = new EscherContainerRecord(); EscherSpRecord sp = new EscherSpRecord(); EscherOptRecord opt = new EscherOptRecord(); EscherClientDataRecord clientData = new EscherClientDataRecord(); spContainer.RecordId=EscherContainerRecord.SP_CONTAINER; spContainer.Options=(short)0x000F; sp.RecordId=EscherSpRecord.RECORD_ID; sp.Options=(short)((EscherAggregate.ST_DONUT << 4) | 0x2); sp.ShapeId=shapeId; if (hssfShape.Parent == null) sp.Flags=EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE; else sp.Flags=EscherSpRecord.FLAG_CHILD | EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE; opt.RecordId=EscherOptRecord.RECORD_ID; opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TRANSFORM__ROTATION, false, false, 0)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, false, false, hssfShape.DrawAreaWidth)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, false, false, hssfShape.DrawAreaHeight)); opt.AddEscherProperty(new EscherShapePathProperty(EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX)); EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0]); verticesProp.NumberOfElementsInArray=(hssfShape.XPoints.Length + 1); verticesProp.NumberOfElementsInMemory=(hssfShape.XPoints.Length + 1); verticesProp.SizeOfElements=unchecked((short)0xFFF0); for (int i = 0; i < hssfShape.XPoints.Length; i++) { byte[] data = new byte[4]; LittleEndian.PutShort(data, 0, (short)hssfShape.XPoints[i]); LittleEndian.PutShort(data, 2, (short)hssfShape.YPoints[i]); verticesProp.SetElement(i, data); } int point = hssfShape.XPoints.Length; byte[] data1 = new byte[4]; LittleEndian.PutShort(data1, 0, (short)hssfShape.XPoints[0]); LittleEndian.PutShort(data1, 2, (short)hssfShape.YPoints[0]); verticesProp.SetElement(point, data1); opt.AddEscherProperty(verticesProp); EscherArrayProperty segmentsProp = new EscherArrayProperty(EscherProperties.GEOMETRY__SEGMENTINFO, false, null); segmentsProp.SizeOfElements=(0x0002); segmentsProp.NumberOfElementsInArray=(hssfShape.XPoints.Length * 2 + 4); segmentsProp.NumberOfElementsInMemory=(hssfShape.XPoints.Length * 2 + 4); segmentsProp.SetElement(0, new byte[] { (byte)0x00, (byte)0x40 }); segmentsProp.SetElement(1, new byte[] { (byte)0x00, (byte)0xAC }); for (int i = 0; i < hssfShape.XPoints.Length; i++) { segmentsProp.SetElement(2 + i * 2, new byte[] { (byte)0x01, (byte)0x00 }); segmentsProp.SetElement(3 + i * 2, new byte[] { (byte)0x00, (byte)0xAC }); } segmentsProp.SetElement(segmentsProp.NumberOfElementsInArray - 2, new byte[] { (byte)0x01, (byte)0x60 }); segmentsProp.SetElement(segmentsProp.NumberOfElementsInArray - 1, new byte[] { (byte)0x00, (byte)0x80 }); opt.AddEscherProperty(segmentsProp); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__FillOK, false, false, 0x00010001)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINESTARTARROWHEAD, false, false, 0x0)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDARROWHEAD, false, false, 0x0)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, false, false, 0x0)); AddStandardOptions(shape, opt); EscherRecord anchor = CreateAnchor(shape.Anchor); clientData.RecordId=(EscherClientDataRecord.RECORD_ID); clientData.Options=(short)0x0000; spContainer.AddChildRecord(sp); spContainer.AddChildRecord(opt); spContainer.AddChildRecord(anchor); spContainer.AddChildRecord(clientData); return spContainer; }