the error is still there ..POI 2.5.1 does not support this feature .....Is there any other way by which this can be implemented ..
[javac] ExcelKurveAction.java:688: cannot find symbol [javac] symbol : variable PICTURE_TYPE_PNG [javac] location: class org.apache.poi.hssf.usermodel.HSSFWorkbook [javac] pictureIndex = wb.addPicture( bos.toByteArray(),HSSFWorkbook.PICTURE_TYPE_PNG); [javac] ^ [javaca:704: cannot find symbol [javac] symbol : method createPicture(org.apache.poi.hssf.usermodel.HSSFClientAnchor,int) [javac] location: class org.apache.poi.hssf.usermodel.HSSFPatriarch [javac] patriarch.createPicture(anchor, loadPicture( "/images/logos/DC.png", wb )); [javac] ^ [javac] Note: * uses or overrides a deprecated API. [javac] Note: Recompile with -Xlint:deprecation for details. [javac] Note: Some input files use unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. [javac] 2 errors [EMAIL PROTECTED] 06.12.2006 17:35 Bitte antworten an poi-user@jakarta.apache.org An poi-user@jakarta.apache.org Kopie Thema Re: Antwort: Re: Antwort: Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent Not tested this so I cannot be sure but I think it is just a spelling error. You have entered; wb.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG); and I think it should be; wb.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYPE_PNG); You may have miss-typed the name of the static variable. [EMAIL PROTECTED] wrote: [javac]reports\action\ExcelKurveAction.java:669: cannot find symbol [javac] symbol : variable PICTURE_TYP_PNG [javac] location: class org.apache.poi.hssf.usermodel.HSSFWorkbook [javac] pictureIndex = wb.addPicture( bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG); [javac] ^ [javac]reports\action\ExcelKurveAction.java:686: cannot find symbol [javac] symbol : method createPicture(org.apache.poi.hssf.usermodel.HSSFClientAnchor,int) [javac] location: class org.apache.poi.hssf.usermodel.HSSFPatriarch [javac] patriarch.createPicture(anchor, loadPicture( "/images/logos/DC.png", wb )); [javac] ^ Hope this helps Regards [EMAIL PROTECTED] 06.12.2006 08:32 Bitte antworten an poi-user@jakarta.apache.org An poi-user@jakarta.apache.org Kopie Thema Re: Antwort: Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent What error/exception are you seeing when you try to add the image? Could you post the statctrace please - if there is one? [EMAIL PROTECTED] wrote: private int loadPicture( String path, HSSFWorkbook wb ) throws IOException { int pictureIndex; FileInputStream fis = null; ByteArrayOutputStream bos = null; try { fis = new FileInputStream( path); bos = new ByteArrayOutputStream( ); int c; while ( (c = fis.read()) != -1) bos.write( c ); pictureIndex = wb.addPicture( bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG); } finally { if (fis != null) fis.close(); if (bos != null) bos.close(); } return pictureIndex; } private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws IOException { HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); HSSFClientAnchor anchor; anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14); //anchor.setAnchorType(2); patriarch.createPicture(anchor, loadPicture( "/images/logos/DC.png", wb )); } Thanks for the reply ..See I did the following as said in the guide ..but gives error on addPicture () and CreatePicture() ....Iam using POI 2.5 .Have alook at the code snippet also if needed which states exactly what you recomended .. ..also Iam trying to add a image through POI only .. Thanks n Regards HEpzibah [EMAIL PROTECTED] 05.12.2006 18:39 Bitte antworten an poi-user@jakarta.apache.org An poi-user@jakarta.apache.org Kopie Thema Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent .png should be fine. I have cut the folowing from the user guide to see if it helps at all. Images are part of the drawing support. To add an image just call createPicture() on the drawing patriarch. At the time of writing the following types are supported: PNG JPG DIB It is not currently possible to read existing images and it should be noted that any existing drawings may be erased once you add a image to a sheet. // Create the drawing patriarch. This is the top level container for // all shapes. This will clear out any existing shapes for that sheet. HSSFPatriarch patriarch = sheet5.createDrawingPatriarch(); HSSFClientAnchor anchor; anchor = new HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7); anchor.setAnchorType( 2 ); patriarch.createPicture( anchor, loadPicture( "src/resources/logos/logoKarmokar4.png", wb )); >From reading that it seems that you will have to insert the image rather than copy it from the spreadsheet. [EMAIL PROTECTED] wrote: Iam using .png [EMAIL PROTECTED] 05.12.2006 13:48 Bitte antworten an poi-user@jakarta.apache.org An poi-user@jakarta.apache.org Kopie Thema Re: Add images to a cell using POI 2.5 ---Help urgent I am pretty sure you should be able to use a template that includes an image and then create a workbook based upon that template. What type of image are you using (.jpg, .png, .bmp)? It may be that it is simply the 'wrong' type. [EMAIL PROTECTED] wrote: I want to have a logo in a cell and tried having it part of the template and loading it .. While trying to open gives error which otherwise works perfectly without the image .. Therefore tried the following code... But POI 2.5 does not support createPicture() method of patriach and addPicture () of workbook .. Is there a way out for this ..please help .. Regards Hepzibah private int loadPicture( String path, HSSFWorkbook wb ) throws IOException { int pictureIndex; FileInputStream fis = null; ByteArrayOutputStream bos = null; try { fis = new FileInputStream( path); bos = new ByteArrayOutputStream( ); int c; while ( (c = fis.read()) != -1) bos.write( c ); pictureIndex = wb.addPicture( bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG); } finally { if (fis != null) fis.close(); if (bos != null) bos.close(); } return pictureIndex; } private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws IOException { HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); HSSFClientAnchor anchor; anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14); //anchor.setAnchorType(2); patriarch.createPicture(anchor, loadPicture( "/images/logos/DC.png", wb )); } --------------------------------- Access over 1 million songs - Yahoo! Music Unlimited. --------------------------------- Need a quick answer? Get one in minutes from people who know. Ask your question on Yahoo! Answers. --------------------------------- Want to start your own business? Learn how on Yahoo! Small Business. --------------------------------- Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.