DateTime date = new DateTime();
date = DateTime.Now;
this.Response.Clear();
this.Response.Buffer= true;
this.Response.Charset="utf-8";
this.Response.AppendHeader("Content-Disposition","attachment;filename=Manufacturing Workshops list-"+date.Year+"_"+date.Month+"_"+date.Day+".xls");
this.Response.ContentEncoding=System.Text.Encoding.UTF8;
this.Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = System.Globalization.CultureInfo.CurrentCulture;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.RenderControl(oHtmlTextWriter);
this.Response.Write(oStringWriter.ToString());
this.Response.End();
date = DateTime.Now;
this.Response.Clear();
this.Response.Buffer= true;
this.Response.Charset="utf-8";
this.Response.AppendHeader("Content-Disposition","attachment;filename=Manufacturing Workshops list-"+date.Year+"_"+date.Month+"_"+date.Day+".xls");
this.Response.ContentEncoding=System.Text.Encoding.UTF8;
this.Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = System.Globalization.CultureInfo.CurrentCulture;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.RenderControl(oHtmlTextWriter);
this.Response.Write(oStringWriter.ToString());
this.Response.End();
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
__________________________________________________________
引用,
excel类型库
microsoft.office.core
microsoft.office.tools.Common