Hello Jon, Sorry to say that I cannot be of any help directly but have you performed a search of the list yet? I seem to remember that someone posted a very useful bit of code that illustrated how to add an image and control the size - again my old brain is telling me it has something to do with the default font but I could well be wrong. I am sorry to say that I cannot search the list myself as I access it through Nabble.
If I have the opportunity this evening, I will have a good search around and see if I can find anything out for you or make any sense of adding images to sheets and will post a message if I come up with any information. Tomorrow is an 'office' day for me so I should have one or two opportunities to play with the api and again will post if I manage to solve the problem of setting an image to a fixed size. Yours Mark B Jon Brisbin-2 wrote: > > I've not found a lot of documentation on how to add images to > spreadsheets using POI and the examples I have found don't seem to > work like I expect. I could really use some help here. > > I'm trying to add a company logo graphic (which I pull from our > intranet via Java URL object) to a HSSFWorkbook I create. My code > looks like this: > > int picIndex = workbook.addPicture(getNPCLogo(), > Workbook.PICTURE_TYPE_PNG); > Drawing pat = currentSheet.createDrawingPatriarch(); > HSSFClientAnchor anchor = new HSSFClientAnchor(); > anchor.setAnchorType(2); > anchor.setCol1((short) 0); > anchor.setCol2((short) 1); > anchor.setRow1(0); > anchor.setRow2(1); > Picture pic = pat.createPicture(anchor, picIndex); > > The problem I'm having, though, is that this creates an image that > fills the height and width of the first cell, which is not what I want > (it looks stretched out). What I want is for the image to appear at > it's normal width and height at a specific position I give it, but I > can't seem to understand how to make that happen. When I replace > setCol1 et. al. with setDx1 and setDy1, etc... I get an image that is > a fraction of the height and width of the original image. I don't > understand what units the setDx2 and setDy2 is expecting (and it's not > documented anywhere I've found) so I can't get the image to the right > size. > > Can someone please give me some clear guidance (beyond what little > code is out there in the wild which I've tried variations on ad > nauseum) on how to accomplish this using POI 3.5 beta5? I'm sure I'm > just missing a little something that I don't understand but I can't > see what that is. > > Thanks! > > Jon Brisbin > Portal Webmaster > NPC International, Inc. > -- View this message in context: http://www.nabble.com/Problems-adding-logo-image-to-spreadsheet-tp23851486p23854589.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]
