I draw two lines by using HSSFSimpleShape. I expected that it looks like a V mark ("\/"). But it looks "\_" at the excel of ms office 2007. and looks "\ \" at the excel of ms office 2003. If end_x or end_y is greater than start_x or start_y then it dose not go properly. The following is the part of source. { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.setAnchor( (short)1, 1, 0, 0, (short) 1, 1, 512, 100); HSSFSimpleShape shape1 = patriarch.createSimpleShape(a1); shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE); } { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.setAnchor( (short)1, 1, 512, 100, (short) 1, 1, 1024, 0); HSSFSimpleShape shape1 = patriarch.createSimpleShape(a1); shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE); } The original source code from http://www.koders.com/java/fidEACAA8D909E44C6F130B34CFA76FDA1738FD719D.aspx
I did some analysis: it seems Excel and OpenOffice use a flag "FLIPVERT" and reverse vertical coordinates for the second drawing, so a workaround currently is to use the following: HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.setAnchor( (short)2, 2, 512, 0, (short) 2, 2, 1024, 100); HSSFSimpleShape shape1 = patriarch.createSimpleShape(a1); shape1.setFlipVertical(true); shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE); we probably need to search the spec if this behavior is described, when the record is serialized, the data ends up in two separate sub-records of the EscherContainerRecord: Child 0: org.apache.poi.ddf.EscherSpRecord: RecordId: 0xF00A Version: 0x0002 ShapeType: 0x0014 ShapeId: 1025 Flags: FLIPVERT|HAVEANCHOR|HASSHAPETYPE (0x00000A80) ... Child 2: org.apache.poi.ddf.EscherClientAnchorRecord: RecordId: 0xF010 Version: 0x0000 Instance: 0x0000 Flag: 0 Col1: 2 DX1: 512 Row1: 2 DY1: 0 Col2: 2 DX2: 1024 Row2: 2 DY2: 100 Extra Data: No Data
I looked at the spec, there is no mention of this behavior and I don't see an easy way of handling this inside POI with correct backwards compatibility. Therefore I have updated javadoc via r1621586 to mention that some flipping might be necessary. So overall this Bug is WONTFIX as we don't fix it in POI as the behavior is caused by Excel itself in an undocumented way.