asp.net Grid 導(dǎo)出Excel實現(xiàn)程序代碼
更新時間:2012年12月29日 10:07:55 作者:
看了FineUI中的將Grid導(dǎo)出為Excel的實現(xiàn)方法,實際上是可以非常簡單。看來很難的問題,變換一種思路就可以非常簡單
1. Aspx后臺代碼輸出Content Type信息
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>")
這樣的實現(xiàn)對于簡單的導(dǎo)出數(shù)據(jù)到Excel已經(jīng)足夠了。
用法很簡單
引入 bootstrap.js 和壓縮包里的 export-all.js 就可以使用了
具體可以參考 main.js (下面是定義Grid的時候 指定一個toolbar 為 xtype: 'exporterbutton')
height: 350,
width: 600,
title: 'Array Grid',
renderTo: 'grid-example',
viewConfig: {
stripeRows: true
},
dockedItems: [
{
xtype: 'toolbar',
dock: 'top',
items: [
{
xtype: 'exporterbutton',
store: myStore
//一下兩項配置 已在Buttion.js中 配置了默認(rèn)路徑 不需要重復(fù)指定
//swfPath: './downloadify.swf',
//downloadImage: './download.png',
//這里可以根據(jù)當(dāng)表格 給 定制導(dǎo)出的文件名
//downloadName:'導(dǎo)出的Excel 名字'
}
]
}
]
復(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>")
這樣的實現(xiàn)對于簡單的導(dǎo)出數(shù)據(jù)到Excel已經(jīng)足夠了。
用法很簡單
引入 bootstrap.js 和壓縮包里的 export-all.js 就可以使用了
具體可以參考 main.js (下面是定義Grid的時候 指定一個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
//一下兩項配置 已在Buttion.js中 配置了默認(rèn)路徑 不需要重復(fù)指定
//swfPath: './downloadify.swf',
//downloadImage: './download.png',
//這里可以根據(jù)當(dāng)表格 給 定制導(dǎo)出的文件名
//downloadName:'導(dǎo)出的Excel 名字'
}
]
}
]
您可能感興趣的文章:
- ASP.NET使用GridView導(dǎo)出Excel實現(xiàn)方法
- asp.net導(dǎo)出excel數(shù)據(jù)的常見方法匯總
- asp.net導(dǎo)出excel的簡單方法實例
- ASP.NET導(dǎo)出數(shù)據(jù)到Excel的實現(xiàn)方法
- Asp.net中DataTable導(dǎo)出到Excel的方法介紹
- ASP.NET用DataSet導(dǎo)出到Excel的方法
- .Net中導(dǎo)出數(shù)據(jù)到Excel(asp.net和winform程序中)
- asp.net生成Excel并導(dǎo)出下載五種實現(xiàn)方法
- asp.net GridView導(dǎo)出到Excel代碼
- ASP.NET 導(dǎo)出到Excel時保留換行的代碼
- asp.net實現(xiàn)Gradview綁定數(shù)據(jù)庫數(shù)據(jù)并導(dǎo)出Excel的方法
相關(guān)文章
一天精通asp.net的學(xué)習(xí)經(jīng)驗小結(jié)
一天精通asp.net的學(xué)習(xí)經(jīng)驗小結(jié)2010-02-02
ASP.NET數(shù)據(jù)綁定GridView控件使用技巧
這篇文章主要為大家詳細(xì)介紹了ASP.NET數(shù)據(jù)綁定GridView控件使用技巧,感興趣的小伙伴們可以參考一下2016-03-03
asp.net音頻轉(zhuǎn)換之.amr轉(zhuǎn).mp3(利用七牛轉(zhuǎn)換法)
相信很多人都遇到amr格式的音頻文件不能直接在網(wǎng)頁播放的問題,有人使用QuickTime插件的輔助,下面這篇文章主要給大家介紹了asp.net音頻轉(zhuǎn)換之利用七牛轉(zhuǎn)換法將.amr格式轉(zhuǎn).mp3格式,需要的朋友可以參考借鑒,下面來一起看看吧。2016-12-12
基于.Net中的數(shù)字與日期格式化規(guī)則助記詞的使用詳解
本篇文章是對.Net中的數(shù)字與日期格式化規(guī)則助記詞的使用進行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05

