Same excel file have different cell width with image on different machines

Hi @ahsaniqbalsidiqui,
Thanks for the response.
Can you give me an estimate on how long will take to resolve this problem?

I have another problem when I set the cell width and height the result is not correct.

final Workbook template = new Workbook();
final Worksheet worksheet = template.getWorksheets().get(0);
final Cell cell = worksheet.getCells().get(0, 0);
final URL url = new URL(“http://i.imgur.com/nPfNFVq.jpg”);

try (InputStream is = url.openStream()) {
byte[] imageData = IOUtils.toByteArray(is);

final int index = worksheet.getPictures()
.add(cell.getRow(), cell.getColumn(), cell.getRow() + 1, cell.getColumn() + 1,
new ByteArrayInputStream(imageData));

final Picture pic = worksheet.getPictures().get(index);
pic.setLinkedCell(cell.getName());

worksheet.getCells().setColumnWidthPixel(0, 971);
worksheet.getCells().setRowHeightPixel(0, 546);

System.out.println(“Cell width: " + worksheet.getCells().getColumnWidthPixel(0) + " px”);
System.out.println(“Cell height: " + worksheet.getCells().getRowHeightPixel(0) + " px”);

System.out.println();

System.out.println(“Pic width: " + pic.getWidth() + " px”);
System.out.println(“Pic height: " + pic.getHeight() + " px”);

pic.setPlacement(PlacementType.MOVE);
}

template.save(“result.xlsx”);

Basically, I’m inserting an image inside a cell. I want the image to have a certain size (971x546 px) and the cell to fit the image. This code made this with Aspose Cells 17.7, now with 19.2 is not working. The cell is wider than the image, even thougth, according to the printed values, they should have the same size.

Any thoughts on this problem?
Best regards,
Hugo Freixo

@Hugo_Freixo,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-42924 - Cell with image has different width in macOS

@Hugo_Freixo,
This is to inform you that we have fixed your issue (logged earlier as “CELLSJAVA-42924”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@Hugo_Freixo,
Please try our latest version/fix: Aspose.Cells for Java v19.5.7:
aspose-cells-19.5.7.zip (6.5 MB)

Your issue should be fixed in it.

Let us know your feedback.

Hi ahsaniqbalsidiqui,
I tested my scenario using the fixed build you sent, but what happens is that in one of the machines I tested some images are exported with the wrong width (they lose the width/height ratio) Do you have any idea why this happens?

Attached are the generated files with this scenario. docs.zip (4.5 MB)

Best regards,
Hugo Freixo

@Hugo_Freixo,
I have opened your both output files in macOS but afraid to share that no issue is observed as both the images are placed properly in the cell. I also tried the sample code with the latest version 19.5.7 again in my environment and created an output file. It also contains proper image placement in the cell. Could you please explain the issue in detail along with images after using this latest version?

Hi @ahsaniqbalsidiqui,
The problem is the actual images width. One is wider than the other and it loses the aspect ratio. These files were generated with the same code in different machines.

Screenshot 2019-06-19 at 09.19.27.jpg (1.3 MB)
You can see in this image that one’s width is 10,11’’ and the other is 11,56’’. The last one has a Scale width of 11% instead of 9%

Best regards,
Hugo Freixo

@Hugo_Freixo,
Thank you for sharing the issue details. Could you please provide us the environment details of the machines which are causing different results? It may help us to reproduce the issue here and provide assistance.

Hi @ahsaniqbalsidiqui,
Here is the information:
ERROR MACHINE

UBUNTU:
NAME=“Ubuntu”
VERSION=“14.04.2 LTS, Trusty Tahr”
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME=“Ubuntu 14.04.2 LTS”
VERSION_ID=“14.04”
HOME_URL=“http://www.ubuntu.com/
SUPPORT_URL=“http://help.ubuntu.com/
BUG_REPORT_URL=“Bugs : Ubuntu
JAVA:
java version “1.8.0_171”
Java™ SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot™ 64-Bit Server VM (build 25.171-b11, mixed mode)

OK MACHINE

UBUNTU:
NAME=“Ubuntu”
VERSION=“16.04.5 LTS (Xenial Xerus)”
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME=“Ubuntu 16.04.5 LTS”
VERSION_ID=“16.04”
HOME_URL=“http://www.ubuntu.com/
SUPPORT_URL=“http://help.ubuntu.com/
BUG_REPORT_URL=“Bugs : Ubuntu
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
JAVA:
java version “1.8.0_211”
Java™ SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot™ 64-Bit Server VM (build 25.211-b12, mixed mode)

If you need any extra information, feel free to ask.
Best regards,
Hugo Freixo

@Hugo_Freixo,
Thank you for providing details. Please spare us time to establish the environment for testing this issue. We will write back here once the environment is established and the issue is reproduced.

@Hugo_Freixo,
Could you please identify the exact ISO file for the ERROR MACHINE from the following links? If it is not in the list, please share from any other source which you have used.

Hi @ahsaniqbalsidiqui,

Here’s the requested information:
The ISO file for the ERROR MACHINE is 64-bit PC (AMD64) server install image in the first link.
MicrosoftTeams-image.png (62.9 KB)

Best regards,
Hugo Freixo

@Hugo_Freixo,
Thank you for the confirmation. Please spare us little time to establish the environment and test the issue. We will write back here as soon as some feedback is ready to share with you.

Hi @ahsaniqbalsidiqui,

Is there any update on this issue?

Best regards,
Hugo Freixo

@Hugo_Freixo,
I am afraid it is not resolved yet. We will inform you as soon as some update will be available.

@Hugo_Freixo,
We have investigated the issue in detail and observed that this issue is due to difference in fonts. You may copy all fonts of the working machine to another machine. The issue should be caused that referred fonts in the file could not be found. Please give it a try and share the feedback.

Hi @ahsaniqbalsidiqui,

I removed all the fonts from the failing machine and copied all the ones from the working machine.
The pixel difference between cells does not exist anymore. Thank you very much.
We’re still waiting on a fix for another issue Different cell sizes retrieved on different machines (MacOS and Windows) for same Excel file - #12 by amjad.sahi

How long will it take to solve?
How can I follow the issue’s progress? You said the issue was logged as CELLSJAVA-42920 - Same excel file have different cell size on different machines, but I don’t know how to follow it.

Best regards,
Hugo Freixo

@Hugo_Freixo,
We are glad to know that one of your issues is resolved by copying fonts from the working machine. Regarding the issue CELLSJAVA-42920, neither it is resolved nor any ETA is available as it is still under investigation. You may keep on checking the status of the ticket and we will also write back here as soon as any update is available for this issue.

We are sorry for any inconvenience caused to you in this regard.

@Hugo_Freixo,
We have investigated CELLSJAVA-42920 further and like to share that we have got the same result on macOS and Window. Screenshots are attached for your reference.
od.jpg (68.3 KB)
autofit.jpg (277.7 KB)

Hi @ahsaniqbalsidiqui,

That’s good news.Did you get that with your Development version or did you use a released version?

Best regards,
Hugo Freixo