OutPutExcel.aspx <% @ Page language = " c# " Codebehind = " OutPutExcel.aspx.cs " AutoEventWireup = " false " Inherits = " eMeng.Exam.OutPutExcel " %> <! DOCTYPE HTML PUBLIC " -//W3C//DTD HTML 4.0 Transitional//EN " > < HTML > < HEAD > < title > OutPutExcel </ title > </ HEAD > < body > < form id = " Form1 " method = " post " runat = " server " > < asp:DataGrid id = " DataGrid1 " runat = " server " ></ asp:DataGrid > < asp:Button id = " Button1 " runat = " server " Text = " 输出到Excel " ></ asp:Button > </ form > </ body > </ HTML > OutPutExcel.aspx.cs using System; using System.Collections; using System.ComponentModel;