public static string ExportToExcel(GridView gridView, TextExportMode exportMode, string fileName) { try { if (fileName == null) fileName = GetSaveExcelFileName(); var extension = Path.GetExtension(fileName); if (extension == ".xls") { gridView.ExportToXls(fileName, new XlsExportOptions( exportMode, true)); } else if (extension == ".xlsx") { gridView.ExportToXlsx(fileName, new XlsxExportOptions( exportMode, true)); } else { return ""; } return fileName; } catch { } return ""; }
public static string ExportToExcel(PivotGridControl pivot, TextExportMode exportMode) { try { var fileName = GetSaveExcelFileName(); var extension = Path.GetExtension(fileName); if (extension == ".xls") { pivot.ExportToXls(fileName, new XlsExportOptions( exportMode, true)); } else if (extension == ".xlsx") { pivot.ExportToXlsx(fileName, new XlsxExportOptions( exportMode, true)); } else { return ""; } return fileName; } catch { } return ""; }
public static string ExportToExcel(GridView gridView, TextExportMode exportMode) { return ExportToExcel(gridView, exportMode, null); }