Excel anchores shapes to rows and columns. The first 2 parameters in XSSFClientAnchor are X and Y offsets in the first (top-left) cell, then follow X and Y offsets in the second cell (bottom-right). Then follow coordinates of the first and second cells.
The offsets are measured in EMUs (english metric units). There are 12700 emus in a point , see EMU_PER_PIXEL and EMU_PER_POINT constants in the XSSFShape class. To position a rectange with given width and height at a point (x,y) you need to transform all coordinates to Excel coordinate system, i.e x1 --> col1 + dx1 y1 --> row1 + dy1 x2 --> col2 + dx2 y2 --> row2 + dy2 A good example how to perform such a transformation is XSSFPicture.getPreferredSize - this method computes anchor for a picture which is very close to what you need. Yegor On Wed, Oct 10, 2012 at 12:44 PM, stefan.chonov <[email protected]> wrote: > Hi! > > I need to export a few shapes into excel file. I using Excel 2007. > > I would like to put a rectangle shape on given x and y points. I don't > understand how the XSSFClientAnchor class works. How to calculate the start > point of the X and Y coordinates? How to calculate end points of X and Y? In > what measure are the first 4 parameters of the XSSFClientAnchor class? > > > > > > -- > View this message in context: > http://apache-poi.1045710.n5.nabble.com/How-to-calculate-location-of-the-shape-in-Excel-2007-tp5711113.html > Sent from the POI - User mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
