All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
将GridView内容导出到Excel或Word中_[Asp.Net教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/1/30 1:35:16 Browse times: 288 Comment times: 0

将GridView内容导出到Excel或Word中_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

将GridView内容导出到Excel或Word中_[Asp.Net教程]

前台页面:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ExportDemo.aspx.cs" Inherits="ExportDemo" %>

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>GridView导出到Excel或Word文件——周公的博客:http://blog.csdn.nettitle>
head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="gvPersonList" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Id" HeaderText="编号" />
<asp:BoundField DataField="Name" HeaderText="姓名" />
<asp:TemplateField HeaderText="性别">
<ItemTemplate>
<%# Eval("Sex").ToString()=="true"?"":"" %>
ItemTemplate>
asp:TemplateField>
<asp:BoundField DataField="Age" HeaderText="年龄" />
<asp:TemplateField HeaderText="婚否">
<ItemTemplate>
<%# Boolean.Parse(Eval("Married").ToString())==true?"":"" %>
ItemTemplate>
asp:TemplateField>
Columns>
asp:GridView>
<asp:Button ID="btnToExcel" runat="server" OnClick="btnToExcel_Click" Text="导出到Excel" />
<asp:Button ID="btnToWord" runat="server" OnClick="btnToWord_Click" Text="导出到Word" />
div>
form>
body>
html>




There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.