Free Support Forum - aspose.com

Not Setting Backgroung image in Excel file at JDK 1.4 varsion

Hi,

In JDK1.4, background image is not setting in Excel file. Using JDK1.4' Aspose.Cells.jar file. It is not throwing any exception . In JDK1.5 it's workimg fine.

Code:

Workbook workbook = new Workbook();
workbook.open("C:\\test.xls");
Worksheets worksheets = workbook.getWorksheets();
int number = workbook.getWorksheets().size();

for (int i = 0; i < number; i++) {
Worksheet sheet = worksheets.getSheet(i);
File file = new File(watermark);
byte[] imageData = new byte[(int) file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(imageData);
sheet.setBackground(imageData);

}

workbook.save("c:\\text.xls");

Regards,

Dheeraj

Hi,

Thank you for considering Aspose.

We have tested our latest fixes with JDK 1.4.2_11 and they work fine. Please try the attached latest version and let us know if it works fine for you.

Thank You & Best Regards,

Hi,

Still i'm getting the same problem. Back groud image is not adding in Excel file at JDK 1.4 version. Can you please send the sample code?

Regards,

Dheeraj

Hi,

Thank you for considering Aspose.

Well, for setting background image of worksheet, our test code is simple as following:

File file = new File("draft.gif");

byte[] imageData = new byte[(int)file.length()];

FileInputStream fis = new FileInputStream(file);

fis.read(imageData);

sheet.setBackground(imageData);

The background image of worksheet is applied fine in the generated excel file (for both JDK1.4 and 1.5).

Thank You & Best Regards,

Hi,

Still i'm getting the same issue. Not attaching the back ground image in excel file at 1.4 jdk. Attached the code, jars and imgae file. Can you please test this code in you side at 1.4 java version?

Thanks,

Dheeraj

Hi,

Thank you for considering Aspose.

I am afraid, we cannot support to set such image ("PreReleased.bmp) as background of sheet because the bmp file is not supported by Image-related APIs of JDK1.4.

Thank You & Best Regards,