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

Free Support Forum - aspose.com

AutoFitRow() does not work properly

If I add the following text to a cell, and set the column width to 12, and the Style.IsTextWrapped property to true, calling worksheet.AutoFitRow() on that row does not stretch the row far enough to display all of the text. Why?

"XX - XXXXXXXX XXXXXXX XXXXXX XXX XXXXXXXX XXX XXXXXX XXXXXXXXX XXXXXX XXX"

Cheers,

Haydn

PS I’m using 1.8.1.0.

Dear Haydn

Thanks for your consideration.

This problem is caused by space characters in the string. If you replace space characters with other characters, you will found that AutoFitRow works well. I will fix this bug in next hotfix within one week.
Thanks for your patience.

@Haydn,
We are glad to inform that we have introduced new upgraded product Aspose.Cells which has replaced Aspose.Excel. This new product has much more advanced features and is far ahead in performance and support for latest features in MS Excel. It provides features to autofit rows and colums as demonstrated below:

// Opening the Excel file through the file stream
Workbook workbook = new Workbook(fstream);

// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];

// Auto-fitting the 3rd row of the worksheet
worksheet.AutoFitRow(1);

// Saving the modified Excel file
workbook.Save(dataDir  + "output.xlsx");

// Closing the file stream to free all resources
fstream.Close(); 

For more information on opening different versions of Excel files, please follow the link below:
AutoFit Rows and Columns

Download the latest version of Aspose.Cells for .NET from the following link:
Aspose.Cells for .NET (Latest Version)

You can download the latest demos here.