Adding image with percentage to Excel worksheet in Java

Hi,
I am currently using evaluation version of Aspose.Cells (7.0.0), I am trying to add the image with percentage and aspect ratio would remain as is.
I am using the PictureCollection.add(int upperLeftRow, int upperLeftColumn, java.io.InputStream stream, int widthScale, int heightScale) where in api documentation found it says widthScale and heighScale are in “a percentage”.
In the sample code below as you can see I am adding two images from the same source with dimensions 204 X 1082, for the first image I have set widthScale and heightScale as 30 and 30, and for second I have set those scales to 50 and 50.
The issue is when I open the excel file created, both the images are not in the percentage as they should be, the first image which was 30% X 30% was changed to 40% X 40% and the second image which was 50% X 50% was changed to 67% X 67%.
Am I missing something here or is it an issue.

Below is the sample code and I am attaching the screen shot with comments of the excel file generated.

package com.asposeExe;

import java.io.InputStream;

import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class AposeExeMain {

public static void main(String[] args) throws Exception {
Workbook workbook = new Workbook();
String sheetName = “ImgSheet”;
Worksheet worksheet = workbook.getWorksheets().add(sheetName);

InputStream imgStream = AposeExeMain.class.getClassLoader().getResourceAsStream(“img-vertical.JPG”);
*worksheet.getPictures().add(0, 2, imgStream,  **30** ,  **30** );*

imgStream = AposeExeMain.class.getClassLoader().getResourceAsStream(“img-vertical.JPG”);
*worksheet.getPictures().add(0, 6, imgStream,  **50** ,  **50** );*

workbook.save(“ImageTest.xls”);
}
}

Hi,


After an initial test, we could not find your mentioned issue with our sample image file. We are using v7.0.1.x. We need your source JPG file here, please attach it here, so that we could evaluate your issue. If we found the issue, we will log it into our database to figure it out soon.

Thank you.

Thanks for the quick replay.


Please find the attached source image I was using.

thank you,
mpujari

Hi,
Came across some interesting finding, if I want to set the scale to some value x, then we can accomplish this by setting 75% of x value i.e. if I wanted to set the scale to 30 (both width and height) then 75% of 30 would be 22 (aprox), so when I set the scale value in the program as 22 I am getting 30% in the excel.
if I want to scale the images in excel with 10, 30, 50, 70 and 100, then in the program I had to set the scale as 7, 22, 37, 52 and 75.
Just post as I thought it might help you guys to figure out am I doing something wrong or is it a issue.

thanks
mpujari

Hi,

Thanks for the source image file.

I have tested your code with your source image file and found the issue as you mentioned. The images size properties does not correspond to the source code.

Also, we noticed that you are right regarding your interesting findings.

I have logged a ticket for your issue with an id: CELLSJAVA-30899. We will figure it out soon.

Thank you.

Hi,


Please try the attached version v7.0.1.5, we have fixed the issue now.

Thank you.

Hi,
thanks for the update, now it works like charm.

Mahesh Pujari

The issues you have found earlier (filed as 30899) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.