AutoFitRow sizes the row differently from Microsoft Excel when AutoFitMergedCell is set to false.
See attached code and comment in it and attached Workbook in order to reproduce problem.
public static void TestRowAutoFit()
{
Workbook sourceWorkbook = new Workbook(@“C:\Aspose Auto Row Height Issue\AutoRowHeightIssue.xlsb”);
// TEST 1 - AutoFitMerged Cells = true
// TEST 2 - Run with AutoFitMerged Cells = false
AutoFitterOptions autoFitterOptions = new AutoFitterOptions {AutoFitMergedCells = false, IgnoreHidden = false, OnlyAuto = false};
double heightBeforePoints = sourceWorkbook.Worksheets[0].Cells.CreateRange(“1:1”).RowHeight;
int heightBeforePixels = sourceWorkbook.Worksheets[0].Cells.GetRowHeightPixel(0);
double heightBeforeFromGetRowHeight = sourceWorkbook.Worksheets[0].Cells.GetRowHeight(0);
// Aspose heightBeforePoints = 12.75, heightBeforePixels = 17, heightBeforeFromGetRowHeight = 12.75
// Microsoft Excel shows Heights in opened spreadsheet as 12.75 points and 7 Pixels. (Display Dpi is 96)
// All matching and correct.
sourceWorkbook.Worksheets[0].AutoFitRow(0, 0, 16383, autoFitterOptions);
double heightAfterPoints = sourceWorkbook.Worksheets[0].Cells.CreateRange(“1:1”).RowHeight;
int heightAfterPixels = sourceWorkbook.Worksheets[0].Cells.GetRowHeightPixel(0);
double heightAfterFromGetRowHeight = sourceWorkbook.Worksheets[0].Cells.GetRowHeight(0);
sourceWorkbook.Save(@“C:\Aspose Auto Row Height Issue\AutoRowHeightIssue - Test Results.xlsb”, SaveFormat.Xlsb);
// TEST RESULTS:
// TEST 1 - When using AutoFitMerged Cells = true in AutoFitterOptions (see above)
// Microsoft Excel shows Heights in opened spreadsheet as 22.5 points, 30 Pixels.
// Aspose heightBeforePoints = 22.5, heightBeforePixels = 30, heightBeforeFromGetRowHeight = 22.5
// All matching and correct.
// TEST 2 - When using AutoFitMerged Cells = false in AutoFitterOptions (see above)
// Microsoft Excel shows Heights in opened spreadsheet as 18.0 points, 24 Pixels.
// Aspose heightBeforePoints = 22.5, heightBeforePixels = 30, heightBeforeFromGetRowHeight = 22.5
// Aspose and Excel values differ.
}
Hi,
// Microsoft Excel shows Heights in opened spreadsheet as 18.0 points, 24 Pixels.
Hi,
Thanks Amjad,
No problems re the confusion…I know only too well how difficult it is tracking down bugs and interpreting things and being able to nail down what is going wrong.
Will you please log a ticket for this one so that we can get a fix in due course.
Many Thanks and if you need more help triaging this one, please do not hesitate to get back to me.
Regards,
Mike
Hi,
Thank you Amjad.
Mike
Hi,
We have evaluated your issue further. Well, the AutoFitterOptions.AutoFitMergedCells is an exclusive
property of Aspose.Cells. There is no such setting or feature in MS Excel. In MS Excel, Autofitter operation will ignore the merged cells as you may confirm. But some of our users of Aspose.Cells want to auto-fit the merged cells too, so we added such property to support this special feature for their needs. If the file contains merged cells, the result will be different from what MS Excel does if AutoFitterOptions.AutoFitMergedCells is true, if AutoFitterOptions.AutoFitMergedCells is false, Aspose.Cells works as per MS Excel. And there is no merged cells in your template file, so could
you show us how to make MS Excel give different results with screen shots? We will check it soon.
Thank you.
The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan