Free Support Forum - aspose.com

Problem adding picture in sheet

Hello,

I'm having troubles adding a picture to a sheet !

Error:

Cause . . . . . : RPG procedure ACELLADDPI in program AAITMRMP1/ACELLSRV
received Java exception "java.lang.IllegalArgumentException: Unsupported
image foramt." when calling method "add" with signature
"(IIIILjava.lang.String;)I" in class "com.aspose.cells.Pictures".

I tried with .jpg and .bmp, but both formats give the same problem !

Is there another problem ? I'm using aspose.cells for java.

Thanks,

Goddeau Hendrik

Hi,

Thanks for considering Aspose.

Well, I don't find the problem, you are mentioning. I tested with both .jpg and .bmp files and it's fine.

Which version of Aspose.Cells for java you are using? Please try the latest hotfix version downloading @: http://www.aspose.com/Community/Forums/thread/95221.aspx

If you still find the problem, kindly send you image with sample code here.

Thank you.

Hello,

I installed the latest fix, but I still have the same problem.

This is my code

piPicture = '/Export/OEMLOGO.bmp'; --> file in IFS

jString = StringToJString(piPicture);
O_Pictures = WorkSheet$getPictures(O_Sh);
lIdx = Pictures$add(O_Pictures:
lRowFr:lColFr:lRowTo:lColTo:jString);
O_Picture = Pictures$get(O_Pictures:lIdx);
Picture$setPlacement(O_Picture:lPlacement);

What am I doing wrong ?

Thanks !

Hi

Are you using the java version?


What's the enviroment for this code to compile and run? I am puzzled by the syntax of it, it doesn't look like valid java code. And some methods invoked in your code haven't been supplied in API, such as the "getPictures" method for Worksheet with an argument.


Another important thing, the software must be used as a complete jar lib, unzip the classes and use them will cause problems.

Yes, I'm using the java version under jdk1.4

This code is written in RPG, where we call java methods.

I'm not a java expert, but I'll try to translate the code for you :
O_Pictures = Sheet.getPictures
lIdx = O_Pictures.Add(r1,c1,r2,c2,picture)
O_Picture = O_Pictures.get(lIdx)

You don't have to worry about my syntax ! Am I taking the wright steps ?

Hi

Would you please try following code in java and give me the output?

ImageInputStream iis = javax.imageio.ImageIO.createImageInputStream(new FileInputStream(picture)); //picture is the picture file you used in you program
Iterator it = javax.imageio.ImageIO.getImageReaders(iis);
if(it.hasNext())
{
String formatName = ((ImageReader)it.next()).getFormatName();
formatName = formatName.toUpperCase();
System.out.println(formatName);
}

thanks.

Which class do I have to include for the iterator ?

Ok, found it : java.util

.BMP gives no result

.jpg gives JPEG

Also unable to add GIF images !

Always the same error !

Java exception "java.lang.IllegalArgumentException: Unsupported
image foramt." when calling method "add" with signature
"(IIIILjava.io.InputStream;)I" in class "com.aspose.cells.Pictures".

Can this be a problem of jdk1.4 ?

Hi,

Could you give a try with JDK 5 or greater and give us the results. And please make sure that you do not unzip the Aspose.Cells component jar lib.

Thank you.

Hi ,

Could you post your image files(jpg,bmp,gif)? We check this issue with your file.

In your previous reply , you said ".BMP gives no result .jpg gives JPEG". So I think the Exception should not be same when add jpg file and bmp file. Could you give us more detail info.?

Hello,

As asked my test images.

In my test it works with jdk5.0 (on pc), but on our iseries I have to use jdk1.4 !

Kind regards.

Hi,

Sorry for our mistake. BMP and WMP are only supported with JDK1.5. We will look into how to add BMP and WMP file with JDK1.4.

We can add jpg picture file with JDK1.4. So could you post your jpg file? We will check it soon.

One of our Jpg-images.

Hi ,

We tried add your jpg file to Excel with JDK1.4. It works fine. Please try the following codes:

Workbook wb = new Workbook();
Pictures pics = wb.getSheet(0).getPictures();
pics.add(0,0,"F:\\FileTemp\\L56763.jpg");
wb.save("F:\\FileTemp\\dest.xls");

If it does not work, could you post your develop info(machine, jdk,ide)?

Does not work.

I'm working on iseries (AS/400) with jdk1.4

Licensed material - Property of IBM.
IBM(R) 32-bit SDK for Windows(R), Java(TM) 2 Technology Edition, Version 1.4.2
IBM(R) 32-bit Runtime Environment for Windows(R), Java(TM) 2 Technology Edition, Version 1.4.2

(c) Copyright Sun Microsystems Inc, 1992, 2003. All rights reserved.
(c) Copyright IBM Corporation, 1998, 2004. All rights reserved.

The Apache Software License, Version 1.1
Copyright (c) 1999-2002 The Apache Software Foundation. All rights reserved.

How do you test for a correct picture extention ?
Do I need other specific classes for this test ?

It seams like these tests never give the disired result !

Thanks.

Hi,

We have not JDK1.4 of Ibm. So please help us test this. We add some debug info into this version. Please test this JPG file with fix and return the debug info.

How am I supposed to see this debug info ?

Thanks