public static void ProcessExport(HttpContext context) { IList <string> columnFields; IDataExportProvider provider; string extension; string portal = context.Request["portal"]; string columns = context.Request["columns"]; //获取导出提供者 switch (context.Request["exportFormat"] ?? "excel") { default: case "excel": provider = new LocaledExcelExportProvider(); extension = "xls"; break; case "csv": provider = new CsvExportProvider(); extension = "csv"; break; case "txt": provider = new TextExportProvider(); extension = "txt"; break; } //获取列名 // Regex reg = new Regex("^export_fields\\[\\d+\\]$", RegexOptions.IgnoreCase); columnFields = new List <string>(); // foreach (string key in context.Request.QueryString.Keys) // { // if (reg.IsMatch(key)) // { // columnFields.Add(context.Request.QueryString[key]); // } // } IDataExportPortal _portal = ExportItemManager.GetPortal(context.Request.QueryString["portal"]); if (_portal == null) { throw new ArgumentNullException("_portal"); } ExportParams parameter = DataExportDirector.GetExportParams(context.Request["params"], columnFields.ToArray()); byte[] bytes = DataExportDirector.Export(_portal, parameter, provider); context.Response.BinaryWrite(bytes); context.Response.ContentType = "application/octet-stream"; context.Response.AppendHeader("Content-Disposition", String.Format("attachment;filename=\"{0:yyyyMMdd-hhssfff}.{1}\"", DateTime.Now, extension)); }
public void ProcessExport(string portal, string columns) { IList <string> columnNames; IDataExportProvider provider; string extension; //获取导出提供者 switch (this.Request["exportFormat"] ?? "excel") { default: case "excel": provider = new ExcelExportProvider(); extension = "xls"; break; case "csv": provider = new CsvExportProvider(); extension = "csv"; break; case "txt": provider = new TextExportProvider(); extension = "txt"; break; } //获取列名 Regex reg = new Regex("^columnNames\\[\\d+\\]$", RegexOptions.IgnoreCase); columnNames = new List <string>(); foreach (string key in this.Request.QueryString.Keys) { if (reg.IsMatch(key)) { columnNames.Add(this.Request.QueryString[key]); } } IDataExportPortal _portal = ExportHelper.GetPortal(portal, this.Request["params"], columnNames.ToArray()); byte[] bytes = DataExportDirector.Export(_portal, provider); this.Response.BinaryWrite(bytes); this.Response.ContentType = "application/octet-stream"; this.Response.AppendHeader("Content-Disposition", String.Format("attachment;filename=\"{0:yyyyMMdd-hhssfff}.{1}\"", DateTime.Now, extension)); }
public static void ProcessExport(HttpContext context) { IList<string> columnFields; IDataExportProvider provider; string extension; string portal = context.Request["portal"]; string columns = context.Request["columns"]; //获取导出提供者 switch (context.Request["exportFormat"] ?? "excel") { default: case "excel": provider = new LocaledExcelExportProvider(); extension = "xls"; break; case "csv": provider = new CsvExportProvider(); extension = "csv"; break; case "txt": provider = new TextExportProvider(); extension = "txt"; break; } //获取列名 // Regex reg = new Regex("^export_fields\\[\\d+\\]$", RegexOptions.IgnoreCase); columnFields = new List<string>(); // foreach (string key in context.Request.QueryString.Keys) // { // if (reg.IsMatch(key)) // { // columnFields.Add(context.Request.QueryString[key]); // } // } IDataExportPortal _portal = ExportItemManager.GetPortal(context.Request.QueryString["portal"]); if (_portal == null) throw new ArgumentNullException("_portal"); ExportParams parameter = DataExportDirector.GetExportParams(context.Request["params"], columnFields.ToArray()); byte[] bytes = DataExportDirector.Export(_portal, parameter, provider); context.Response.BinaryWrite(bytes); context.Response.ContentType = "application/octet-stream"; context.Response.AppendHeader("Content-Disposition", String.Format("attachment;filename=\"{0:yyyyMMdd-hhssfff}.{1}\"", DateTime.Now, extension)); }
public void ProcessExport(string portal, string columns) { IList<string> columnNames; IDataExportProvider provider; string extension; //获取导出提供者 switch (this.Request["exportFormat"] ?? "excel") { default: case "excel": provider = new ExcelExportProvider(); extension = "xls"; break; case "csv": provider = new CsvExportProvider(); extension = "csv"; break; case "txt": provider = new TextExportProvider(); extension = "txt"; break; } //获取列名 Regex reg = new Regex("^columnNames\\[\\d+\\]$", RegexOptions.IgnoreCase); columnNames = new List<string>(); foreach (string key in this.Request.QueryString.Keys) { if (reg.IsMatch(key)) { columnNames.Add(this.Request.QueryString[key]); } } IDataExportPortal _portal = ExportHelper.GetPortal(portal, this.Request["params"], columnNames.ToArray()); byte[] bytes = DataExportDirector.Export(_portal, provider); this.Response.BinaryWrite(bytes); this.Response.ContentType = "application/octet-stream"; this.Response.AppendHeader("Content-Disposition", String.Format("attachment;filename=\"{0:yyyyMMdd-hhssfff}.{1}\"", DateTime.Now, extension)); }
public static ExportProvider Create(RegExportFormat format, System.IO.StreamWriter writer) { ExportProvider provider = null; switch (format) { case RegExportFormat.NativeRegFormat: provider = new NativeExportProvider(writer); break; case RegExportFormat.XmlFormat: provider = new XmlExportProvider(writer); break; default: provider = new TextExportProvider(writer); break; } return(provider); }