>>The problem is that the cell width and height don't seem to be measured in >>the same units. Exactly. Excel anchores objects against top-left and buttom-right cells. In addition it uses dx and dy for "fine positioning" relative to these cells. So to get the correct aspect ratio you need to know the number of cells and rows your image will occupy. Here it gets complicated :).
The problem is that column width in Excel is expressed in units of 1/256th of a character width of the default font. Conversion from these weird 1/256th units to pixels is not trivial. The minimal steps to calculate width of a cell in pixels are as follows: - get default workbook font. HSSFWorkbook.getFontAt(0) should always return the default one. - get default cell width expressed in 1/256th units. See HSSFSheet.getColumnWidth - Assuming that the default character is "a" compute the width of a surrogate string using Java2D classes. image.width/cell.width is the number of columns to be used in the anchor. I think this logic needs to be buried into POI API somehow. Probably it will be included in future. Regards, Yegor --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] Mailing List: http://jakarta.apache.org/site/mail2.html#poi The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
