Autofit issues

Hi,


I have a couple of questions about the AutoFitColumn() method.

1. I have a column whose values are generated using a formula. Even though am using the AutoFit method at the end, before saving the worksheet, some values in the column are rendered as “####”. Doesn’t the autofit method take values into consideration? Is there a workaround to ensure the column width is set based on values?

2. The documentation at this page says AutoFit methods are time consuming, is there an alternative method where I can set the width of a column?

Thank you.

This message was posted using Page2Forum (attachment) from AutoFit Rows & Columns - Aspose.Cells for .NET

Hi,


Thanks for the sample file.

1) Please<o:p> download and try latest version/fix of the product v6.0.1.5: </o:p>Aspose.Cells for .NET v6.0.1.5.
I have tested your issue with the following code and it works fine with AutoFitColumn method.
e.g
Workbook workbook = new Workbook(“e:\test2\autofitissue\Sample.xlsx”);
workbook.Worksheets[0].AutoFitColumn(0);
workbook.Save(“e:\test2\autofitissue\outautofitting.xlsx”);
The column is auto-fitted fine.

2) Yes, if you have long list of data into lots of cells in a column, then it may take more time to auto-fit it. The reason is we have to calculate all the contents and length of the data filled into the cells to subsequently extend the width to fit the longest list based cell in the column. I think you can also try to manually extend the width of the column using Cells.SetColumnWidth() method instead if you got very large list of data.

Moreover, you may try to use the overloaded version accordingly i.e.,:
AutoFitColumn(int columnIndex, int firstRow, int lastRow)