Well, you have to use the Picture’s methods to set the height/ width. Alternatively, you may draw image by using built-in JAVA APIs to create a thumbnail of the image by using your own code. There is not such APIs to create thumbnail of the image.
Could you provide us your sample code (runnable) or JAVA program to show the issue, we will check it soon. Also, provide your template Excel file and image file here.
I have tested your scenario/ case a bit using a sample PNG image, it works fine. The image gets resized as per my code segment regarding height and width. I used the following sample code with Aspose.Cells for Android v8.3.1 (please try it if you are not already using it). I first uploaded the sample image into \mnt\sdcard path in ADT environment:
e.g
Sample code:
String sdCardPath = Environment.getExternalStorageDirectory().getPath()+ File.separator;
CellsHelper.setFontDir(sdCardPath + “font”);
//Instantiating a Workbook object
Workbook workbook = new Workbook();
WorksheetCollection worksheets = workbook.getWorksheets();
//Obtaining the reference of first worksheet
Worksheet sheet = worksheets.get(0);
//Adding a picture at the location of a cell whose row and column indices
//are 5 in the worksheet. It is “F6” cell
int pictureIndex = sheet.getPictures().add(5 ,5,sdCardPath + “image1.png”);
Picture picture = sheet.getPictures().get(pictureIndex);
picture.setWidth(10);
picture.setHeight(10);
//Saving the Excel file
workbook.save(sdCardPath + “out1.xlsx”);
If you still find the issue with v8.3.1, kindly provide your source Image file here which you are inserting into the cell, we will check it soon.
Yes, it won’t decrease the size of the original picture. It works the same way as MS Excel does, e.g., you may insert the big image into the worksheet cell manually into Ms Excel and then resize it via mouse and save the file, this won’t decrease the size of the Excel file. Well, you need to have the image with lessor size to be inserted (you may either draw or extract image via using your own JAVA code dynamically or should have lessor sized original image).
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.