只需将ContentType 设置为 "application/vnd.ms-excel",表示以Excel方式输出.
代码如下:
DataToExcel.aspx:
%@ Page Language="C#" AutoEventWireup="true" CodeFile="DataToExcel.aspx.cs" Inherits="DataToExcel" %
html xmlns="http://www.w3.org/1999/xhtml"
head runat="server"
titleDataToExcel/title
/head
body
form id="form1" runat="server"
asp:GridView ID="GridView1" runat="server"
/asp:GridView
/form
/body
/htmlDataToExcel.aspx.cs
using System;
using ...[ 查看全文 ]