亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

asp.net Grid 導(dǎo)出Excel實(shí)現(xiàn)程序代碼

 更新時(shí)間:2012年12月29日 10:07:55   作者:  
看了FineUI中的將Grid導(dǎo)出為Excel的實(shí)現(xiàn)方法,實(shí)際上是可以非常簡(jiǎn)單。看來(lái)很難的問(wèn)題,變換一種思路就可以非常簡(jiǎn)單
1. Aspx后臺(tái)代碼輸出Content Type信息

復(fù)制代碼 代碼如下:

Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls");
Response.ContentType = "application/excel";
Response.Write(GetGridTableHtml(Grid1));
Response.End();2. 直接輸出Html代碼
Response.Write(@"
<table border="1">
<tr>
<td>Excel</td>
<td>By Html</td>
</tr>
</table>")


這樣的實(shí)現(xiàn)對(duì)于簡(jiǎn)單的導(dǎo)出數(shù)據(jù)到Excel已經(jīng)足夠了。

用法很簡(jiǎn)單
引入 bootstrap.js 和壓縮包里的 export-all.js 就可以使用了
具體可以參考 main.js (下面是定義Grid的時(shí)候 指定一個(gè)toolbar 為 xtype: 'exporterbutton')

復(fù)制代碼 代碼如下:

height: 350,
width: 600,
title: 'Array Grid',
renderTo: 'grid-example',
viewConfig: {
stripeRows: true
},
dockedItems: [
{
xtype: 'toolbar',
dock: 'top',
items: [
{
xtype: 'exporterbutton',
store: myStore

//一下兩項(xiàng)配置 已在Buttion.js中 配置了默認(rèn)路徑 不需要重復(fù)指定
//swfPath: './downloadify.swf',
//downloadImage: './download.png',

//這里可以根據(jù)當(dāng)表格 給 定制導(dǎo)出的文件名
//downloadName:'導(dǎo)出的Excel 名字'
}
]
}
]

相關(guān)文章

最新評(píng)論