导出 Excel

HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + txtBuyUserID.SelectedValue + ".xls");
HttpContext.Current.Response.Charset = "GB2312";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType = "application/ms-excel";
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
// 读取数据库,循环
tw.Write("交易订单号\t第三方订单号\t充值游戏帐号\t退款金额\t支出帐户\t收入帐户\t退款订单号\t退款人\t收款人\t退款时间\n");
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
tw.Close();
hw.Close();

---------------

aspose  NPIO组件

Dcom组件 

原文地址:https://www.cnblogs.com/jazzka702/p/2726475.html