I am using POI 3.0.2-FINAL .I getthe following error The method addPicture(byte[], int) is undefined for the type HSSFWorkbook
int pictureIndex = wb.addPicture(data, HSSFPicture.PICTURE_TYPE_PNG); On Thu, Dec 11, 2008 at 5:06 PM, David Fisher <[email protected]>wrote: > User Defined Functions are not implemented, nor are they likely to be. They > are unique to any Excel installation and they can present themselves in many > ways and be implemented different technologies that Microsoft and Apple have > introduced. > > If all your ShowPicD function does is place the Image into the cell then > you would need to look into using a version of this code that Yegor posted > on another thread.: > > public void main(String[] args) throws IOException { > //read picture bytes from file system > byte[] data = readPicture("checkbox.jpg"); > > HSSFWorkbook wb = new HSSFWorkbook(); > //picture data is a workbook-global object and can be shared between > multiple pictures > int pictureIndex = wb.addPicture(data, > HSSFPicture.PICTURE_TYPE_JPEG); > > HSSFSheet sheet = wb.createSheet(); > HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); > > //all pictures use the same picture index, thus sharing the same > picture data > HSSFPicture pic1 = patriarch.createPicture(new HSSFClientAnchor(0, > 0, 0, 0, > (short)0, 0, (short)1, 1), pictureIndex); > HSSFPicture pic2 = patriarch.createPicture(new HSSFClientAnchor(0, > 0, 0, 0, > (short)2, 2, (short)3, 3), pictureIndex); > HSSFPicture pic3 = patriarch.createPicture(new HSSFClientAnchor(0, > 0, 0, 0, > (short)4, 4, (short)5, 5), pictureIndex); > > > FileOutputStream out = new > FileOutputStream("shared_picture_data.xls"); > wb.write(out); > out.close(); > } > > Try it out with modification, change the picture type. Understand > HSSFClientAnchor, and I think you'll see how to adapt your code. > > Good luck. > > Regards, > Dave > > > On Dec 11, 2008, at 9:49 AM, Princess wrote: > > I have a function which shows the .png in a cell. >> Now the parameter to the function is a dynamic path >> for eg =ShowPicD("C:\test\a.png") when i try this out >> in excel it works fine .But when i try the same thru POI and >> set this as a formula it throws error and does not show >> the image in the cell .. >> >> Can anyone tell me where do i go wrong >> >> HSSFCell cellImagePath = rowImagePath.getCell((short) 5); >> if(cellImagePath == null){ >> cellImagePath = rowImagePath.createCell((short) 5); >> >> String formula ="ShowPicD(\""+imagePath+"\")"; >> cellImagePath.setCellFormula(formula); >> >> -- >> Hepzibah >> **Hope can be ignited by a spark of encouragement ***** >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- Hepzibah **Hope can be ignited by a spark of encouragement *****
