The picture inserted into an excel document is resized when the height of a row is changed

Hi Aspose Team,

I’ve faced an issue when I cannot keep the initial size of an added picture into an excel document.
Even if the following properties is set to true:
image.png (13.7 KB)

As an example, I’m using this piece of code:

       Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();
        Aspose.Cells.WorksheetCollection worksheets = workbook.Worksheets;
        Aspose.Cells.Worksheet worksheet = worksheets.Add("My Worksheet");

        worksheet.Pictures.Add(0, 0, "sample_640×426.jpeg");

        Aspose.Cells.Cell cell = worksheet.Cells[0, 10];
        cell.Value = "Any text";

        workbook.Save("newWorksheet.xls");

        workbook = new Aspose.Cells.Workbook();
        worksheets = workbook.Worksheets;
        worksheet = worksheets.Add("My Worksheet");

        worksheet.Pictures.Add(0, 0, "sample_640×426.jpeg");

        cell = worksheet.Cells[0, 10];

        //<-- Part that brakes height and height scale
        Aspose.Cells.Style cellStyle = cell.GetStyle();
        cellStyle.Font.Size = 20;
        cell.SetStyle(cellStyle);
        //-->

        cell.Value = "Any text";

        workbook.Save("newWorksheetBrokenHeight.xls");

It creates two different documents with different heights of one picture.

Is it intended behavior or not?
Do we have any solutions to keep the initial image size?

Thanks in advance!

Source img here: sample_640×426.jpeg (86.7 KB)

@Anton_Lysenko,
We have observed this scenario and logged it in our database for detailed analysis. You will be notified here once any update is ready for sharing.

This issue is logged as
CELLSNET-48283 - The picture inserted into an excel document is resized when the height of a row is changed

@Anton_Lysenko,
We have analyzed this issue and observed that for performance, Aspose.Cells does not automatically call auto fit row height, but MS Excel auto fits row height (such that row height automatically matches font) when loading the file.

In xls file, the position and size of the shape are stored as start cell and end cell. So if the row height is fitted before saving the file, wrong start cell and end cell of the shape are stored.

You may please call the AutoFitRows function before saving the file as shown below.

...
...
AutoFitterOptions options = new AutoFitterOptions();
options.OnlyAuto = true;
worksheet.AutoFitRows(options);
workbook.Save("newWorksheetBrokenHeight.xls");

A post was split to a new topic: The picture inserted into an excel document is resized when the default font is changed