@ahsaniqbalsidiqui
I’ve been faced with the same issue, but I’ve used the default style for the workbook and it resizes the image too even though I’ve used the AutoFitRows function before saving the file.
It only works if you set the default font size to 6. Moreover, if you set the default font name to “Segoe UI” it will break more the height of the image.
My code is:
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(); Aspose.Cells.WorksheetCollection worksheets = workbook.Worksheets; Aspose.Cells.Worksheet worksheet = worksheets.Add("My Worksheet"); Aspose.Cells.Style workbookStyle = workbook.DefaultStyle; worksheet.Pictures.Add(0, 0, "sample.jpg"); AutoFitterOptions options = new AutoFitterOptions(); options.OnlyAuto = true; worksheet.AutoFitRows(options); workbook.Save("newWorksheet.xls"); //-------------------------------------------------------------------// workbook = new Aspose.Cells.Workbook(); worksheets = workbook.Worksheets; worksheet = worksheets.Add("My Worksheet"); workbookStyle = workbook.DefaultStyle; workbookStyle.Font.Size = 6; workbookStyle.Font.Name = "Calibri"; workbook.DefaultStyle = workbookStyle; worksheet.Pictures.Add(0, 0, "sample.jpg"); worksheet.AutoFitRows(options); workbook.Save("newWorksheetBrokenHeightCalibri.xls"); //-------------------------------------------------------------------// workbook = new Aspose.Cells.Workbook(); worksheets = workbook.Worksheets; worksheet = worksheets.Add("My Worksheet"); workbookStyle = workbook.DefaultStyle; workbookStyle.Font.Size = 6; workbookStyle.Font.Name = "Segoe UI"; workbook.DefaultStyle = workbookStyle; worksheet.Pictures.Add(0, 0, "sample.jpg"); worksheet.AutoFitRows(options); workbook.Save("newWorksheetBrokenHeightSegoe.xls");
Can we handle it?
Thanks!
sample.jpg (9.8 KB)