public bool Generate <T>(List <T> list, ExtendedGridProperties extendedGridProperties) { bool isError = false; ErrorMessage = string.Empty; if (!String.IsNullOrWhiteSpace(extendedGridProperties.CultureName)) { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(extendedGridProperties.CultureName); } if (!String.IsNullOrWhiteSpace(extendedGridProperties.UICultureName)) { Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(extendedGridProperties.UICultureName); } if (ExportStrategy != null) { if (!ExportStrategy.Export(list, extendedGridProperties)) { isError = true; ErrorMessage = "Error occured while generating the excel sheet."; } } else { ErrorMessage = "Export strategy was not defined."; } return(isError); }
public MemoryStream GenerateExcel(System.Collections.IList list, ExtendedGridProperties extendedGridProperties) { if (!String.IsNullOrWhiteSpace(extendedGridProperties.CultureName)) { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(extendedGridProperties.CultureName); } if (!String.IsNullOrWhiteSpace(extendedGridProperties.UICultureName)) { Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(extendedGridProperties.UICultureName); } if (ExportStrategy != null) { return(ExportStrategy.CreateStream(list, extendedGridProperties)); } else { return(null); } return(null); }
//�Public�Methods�(1)� public static void Export(ListView listView, ExportingOption exportOption, string file) { try { ExportStrategy exportStrategy = GetExportStrategyObject(exportOption); ExportListView exportListView = new ExportListView(exportStrategy); exportListView.Export(listView, file); MessageBox.Show("Exporting Done", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (ArgumentException ex) { DisplayError.Display(ex); } catch (IOException ex) { DisplayError.Display(ex); } }