Ok, thanks a lot, i'll try this as soon as i can.


Yegor Kozlov wrote:
> 
> First four arguments in the HSSFClientAnchor constructor define
> offsets in the top-left and bottom-right cells. You just set it so
> that your lines are not connected.
> 
> Creating a graph and setting all coordinates like you are doing is
> tedious. A better idea is to draw in a shape group and use "normal"
> coordinates
> expressed in pixels, not in columns and rows. You can even use
> EscherGraphics2d which extends java.awt.Graphics2D and can translate
> Graphics2d calls into Excel drawing calls.
> 
> I mean something like this:
> 
>         //drawing will be placed in A1:J30
>         HSSFClientAnchor drawing_anchor = new HSSFClientAnchor( 0, 0, 0,
> 0, (short) 0, 0, (short)9, 29 );
> 
>         HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
>         HSSFShapeGroup group = patriarch.createGroup( drawing_anchor );
>         //internal coordinates
>         group.setCoordinates( 0, 0, 1024, 768);
>         
>         float verticalPointsPerPixel =
> drawing_anchor.getAnchorHeightInPoints(sheet) /
> (float)Math.abs(group.getY2() - group.getY1());
>         java.awt.Graphics2D g2d = new EscherGraphics2d( new
> EscherGraphics( group, workbook, Color.black, verticalPointsPerPixel ) );
>         g2d.drawLine(100, 100, 200, 200);
>         g2d.drawLine(200, 200, 300, 300);
> 
> Note, not all drawing commands are fully supported.  Simple commands
> like  drawLine, drawRect, drawString should work.
>         
>  Yegor
>         
>> Hi all,
> 
>> I try to make graphs in excel using the POI API. To do that, i'm trying
>> to
>> use the HSSFClientAnchor and HSSFSimpleShape objects. But i do not really
>> have the result i expect.
> 
>> To make it simple, for example, i would just like to draw 2 lines :
>> - the first from the B4 cell to the D3 one
>> - the second from the D3 cell to the F3 one.
> 
>> Here is my java code :
> 
>>             HSSFClientAnchor anchor = new HSSFClientAnchor(512, 205, 512,
>> 80, (short) 1, 3, (short) 3, 2);
>>             HSSFSimpleShape shape1 =
>> patriarch.createSimpleShape(anchor);
>>             shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
>>             
>>             HSSFClientAnchor anchor2 = new HSSFClientAnchor(512, 80, 512,
>> 80,
>> (short) 3, 2, (short) 5, 2);
>>             HSSFSimpleShape shape2 =
>> patriarch.createSimpleShape(anchor2);
>>             shape2.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
> 
>> My problem is that the 2 lines are not "connected" together. In fact, i
>> think that i do not really understand how POI displays a line giving an
>> anchor.
> 
>> Does anyone can help me ?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Usage-of-HSSFClientAnchor-tp15611703p15613195.html
Sent from the POI - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to