/// <summary> /// Export data to a stream /// </summary> /// <param name="stream"></param> /// <param name="tList"></param> public static void ExportExcel <TBody, TBodyList>(string configFile, string tableId, string exportId, Stream stream, TBodyList tList, DataValidatingHandler <TBody, TBodyList> dataValidater = null, ExtendDataWritingHandler <TBody, TBodyList> extendDataWriter = null, TableWritingHandler tableHeaderWriter = null, TableWritingHandler tableFooterWriter = null, PageWritingHandler pageHeaderWriter = null, PageWritingHandler pageFooterWriter = null, GetValueHandler <TBody> getValueCallback = null) where TBody : class where TBodyList : class { NPOIExport <TBody, TBodyList> export = CreateNPOIExport <TBody, TBodyList>(configFile, tableId, exportId, dataValidater, extendDataWriter, tableHeaderWriter, tableFooterWriter, pageHeaderWriter, pageFooterWriter, getValueCallback, null); export.Export(stream, tList); export.Dispose(); }
private static NPOIExport <TBody, TBodyList> CreateNPOIExport <TBody, TBodyList>(string configFile, string tableId, string exportId, DataValidatingHandler <TBody, TBodyList> dataValidater, ExtendDataWritingHandler <TBody, TBodyList> extendDataWriter, TableWritingHandler tableHeaderWriter, TableWritingHandler tableFooterWriter, PageWritingHandler pageHeaderWriter, PageWritingHandler pageFooterWriter, GetValueHandler <TBody> getValueCallback, GetValueHandler <object> getHeaderValueCallback) where TBody : class where TBodyList : class { NPOIExport <TBody, TBodyList> export = new NPOIExport <TBody, TBodyList>(configFile, tableId); export.ExportId = exportId; if (dataValidater != null) { export.SourceDataValidating += dataValidater; } if (extendDataWriter != null) { export.ExtendDataWriting += extendDataWriter; } if (tableHeaderWriter != null) { export.TableHeaderWriting += tableHeaderWriter; } if (tableFooterWriter != null) { export.TableFooterWriting += tableFooterWriter; } if (pageHeaderWriter != null) { export.PageHeaderWriting += pageHeaderWriter; } if (pageFooterWriter != null) { export.PageFooterWriting += pageFooterWriter; } if (getValueCallback != null) { export.GetValueCallback += getValueCallback; } if (getHeaderValueCallback != null) { export.GetHeaderValueCallback += getHeaderValueCallback; } return(export); }