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();

解决方案 »

  1.   

    如果用excel的com来做.我知道怎么加.. 这种不清楚..
      

  2.   

    ExcelWorkbook1.Globals.Sheet1.Name;//这个是表一的名字(是显示名称)
      

  3.   

    using System;
    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