We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Issue with AutoFitRow and AutoFitMergedCells

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,


Thanks for the template file and sample code segment.

"// 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 "

I have tested your scenario/ case a bit and found Aspose.Cells renders correct Excel file with first row auto-fitted fine similar to what MS Excel does. When I applied Autofit row operation in MS Excel manually, it also shows similar results. For your information, in the first row there is a single data cell only and there is no merged cell in the sheet at all, so apparently setting auto-merged cells to true or false does not make any difference which it should.

Let us know if we understand you correctly or if you still think any issue, please elaborate it more and give us complete details with screen shots to reproduce the issue on our end, we will check it soon.

Thank you.

Hi,


By the way, do you confirm if Aspose.Cells gives incorrect results at runtime after auto fitting rows operation is made dynamically? e.g
it gives:
Aspose heightBeforePoints = 22.5, heightBeforePixels = 30, heightBeforeFromGetRowHeight = 22.5
where as it should give:
Aspose heightBeforePoints = 18, heightBeforePixels = 24, heightBeforeFromGetRowHeight = 18

And, sorry for the confusion.

Thank you.

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,


Thanks for the confirmation.

Sure, I have logged a ticket with an id “CELLSNET-42601” for your issue into our database. Our concerned developer will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

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 wantto 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.

<o:p></o:p>

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