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

Free Support Forum - aspose.com

Excel Auto-fit Columns operation improvement in Aspose.Cells in .NET


1. When we use AutoFitColumns function, is it possible to add an option to take care about Wrap text property in Cells.


Row 0, I have all cellule with Horizontal alignment = center, Vertical Alignment = center and text wrap enable.

With a Text: Average Distance (km)

Rows 1 to n for this column the maximum value is 1.9 (3 characters).

The actual result of AutoFitColumns is to have Average Distance (km) in one line

The improvement: Average Distance (km) --> 3 lines

2. The autoFitColumns function don't take care about filtering setting --> the choice button can overlap the cell text. Could you please detect the filtering option and add an offset to the autofitcolumns function?



1) Well, Aspose.Cells’ AutoFit Col/Row options works the same way as MS Excel. If your cell with is more than the data inside it, now when you apply auto-fit column(s) options, it would try to auto-fit the data in single line no matter whether you have specified the wrapping text option on for the cell. You may confirm this behavior in MS Excel. If you have different opinion and find any issue in Aspose.Cells, kindly do provide your template file and paste your code here, we will check your issue soon. Also provide your output file here.

2) Generally it should work fine, so when you apply AutoFit cols, it would apply the cells having auto-filters on to fit the data into the cells too. Could you give us your sample file and paste your sample code here to show the issue. Also provide your output file here. We will check your issue soon.

Thank you.


You can find in the zip file:

- the generated version (done by aspose cell)

- the version I did manually (done with my hand in Excel 2010)

- The previous version generated by EEPLUS (you can found it in code complex. we used it before buying aspose product)

- The template file

- Two screen shot to know how I can achieve the manually result

The code:

FileInfo filenameInfo = new FileInfo(m_strFileName);

if (File.Exists(m_strTemplate))


FileInfo templateInfo = new FileInfo(m_strTemplate);


if (filenameInfo.Extension != templateInfo.Extension) // throw new exception

throw new OfficeExtensionNotMatchException(filenameInfo.Extension, templateInfo.Extension);

templateInfo.CopyTo(m_strFileName, true);


if (File.Exists(m_strFileName))


m_workbook = new Workbook(m_strFileName);


else {}// we create it but we don't use it

if (m_sheetNames.Contains(strSheetName))


m_selectedSheet = m_workbook.Worksheets.GetSheetByCodeName(strSheetName);




m_selectedSheet = m_workbook.Worksheets.Add(strSheetName);



m_selectedSheet.Cells.ImportDataTable(datatableHeader, false, 2, 0, false);

m_selectedSheet.Cells.ImportDataTable(datatableData, false, "A6");

/* m_selectedSheet.AutoFitRows(); */ // I try a lot of combination




Thanks for the sample files and screen shots.

We need to check if we can enhance the auto-fit columns operation a bit and make it work similar to MS Excel (if possible). There are some differences in some cells/field data regarding auto-fit cols/row operations.

I simply used the template file provided by you and apply some auto-fit operations

Sample code:

Workbook workbook = new Workbook(“e:\test2\Template_file.xlsx”);

I have logged a ticket with an id “” for your issue. We will look into it soon.

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

Thank you.


Thanks for your posting and using Aspose.Cells for .NET.

We have fixed the issue.

Please download and try this fix: Aspose.Cells for .NET v7.4.3.3 and let us know your feedback.


Sorry didn't work.

Code modification:

AutoFitterOptions option = new AutoFitterOptions();

option.OnlyAuto = true;



For the result and what Excel 2010 do (if I do the file manually) see attachment

Best regards


Thanks for providing us the screen shots.

I have evaluated your issue further. The issue is not resolved as I can still notice the issue as you have mentioned in your attached screen shots. I have logged it against your existing issue “CELLSNET-41693”. We will look into it soon.

Thank you.


Any news on it?

Best regards


I am afraid, your issue is not resolved yet as I checked the status. I have asked the relevant developer to update on it (if possible).

By the way, could you download and try our latest version/fix: Aspose.Cells for .NET v7.5.1.2 and see if auto-fit operations are enhanced.

Thank you.


It's not fixed with, I will test the version next month.

Best regards


This is to inform you that we have fixed your issue (logged earlier as “CELLSNET-41693”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

The issues you have found earlier (filed as CELLSNET-41693) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi