本文实现了将数据库中的数据直接输出到Excel文件格式并在浏览器里输出。下面就是实现的例子:
查看例子
ExcelExport.aspx<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ExcelExport.aspx.vb"Inherits="aspxWeb.mengxianhui.com.ExcelExport"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<title>ExcelExport</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD><body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" runat="server" CellPadding="4" BackColor="White"BorderColor="#CC9966" BorderWidth="1px" BorderStyle="None" Width="100%" Height="100%"Font-Size="9pt" Font-Names="宋体">
<SelectedItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle>
<AlternatingItemStyle BackColor="#FFCC99"></AlternatingItemStyle>
<ItemStyle BorderWidth="2px" ForeColor="#330099" BorderStyle="Solid"BorderColor="Black" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" BorderWidth="2px"ForeColor="#FFFFCC" BorderStyle="Solid" BorderColor="Black" BackColor="#990000"></HeaderStyle>
</asp:datagrid>
</form></body></HTML>
ExcelExport.aspx.vb