private static void AutoSizeColumns(Excel.ExcelNPOIWriter exObj, DataTable tbl, string sheetName) { for (int i = 0; i <= tbl.Columns.Count; i++) { exObj.AutoSizeColumn(i, sheetName); } }