Can't find what you're looking for?

Contact us or post in our forums and we'll help you find an answer.

How to autofit columns of an Excel table in .NET using GcExcel

Issue:

The AutoFit method of GcExcel works fine for normal columns of Excel, but when using a table and calling the AutoFit method of the Columns class, the last character is overlapped by the dropdown sign.

Resolution:

To make it look proper, you can use the code snippet given below:

Workbook wb = new Workbook();
IWorksheet sheet = wb.Worksheets[0];
sheet.Rows[0].Value = new object[] { "TotalColumnHeader", "TotalColumnHeader" };
ITable table = sheet.Tables.Add(sheet.Range["A1:B2"], true);
sheet.Range["A1:B2"].Columns.AutoFit();
for(int i=0;i

Get the Latest Version of Documents for Excel .NET
Download the Free Trial Now