手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >asp.net Grid 导出Excel实现程序代码
asp.net Grid 导出Excel实现程序代码
摘要:1.Aspx后台代码输出ContentType信息复制代码代码如下:Response.ClearContent();Response.Add...

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>")

这样的实现对于简单的导出数据到Excel已经足够了。

用法很简单

引入 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中 配置了默认路径 不需要重复指定

//swfPath: './downloadify.swf',

//downloadImage: './download.png',

//这里可以根据当表格 给 定制导出的文件名

//downloadName:'导出的Excel 名字'

}

]

}

]

【asp.net Grid 导出Excel实现程序代码】相关文章:

asp.net DataGridView导出到Excel的三个方法[亲测]

asp.net 结合mysql存储过程进行分页代码

asp.net下实现URL重写技术的代码

Asp.net 一般处理程序+扩展

asp.net中导出excel数据的方法汇总

asp.net 实现防迅雷等下载工具盗链

asp.net 生成曲线图实现代码

.Net读取Excel 返回DataTable实例代码

asp.net中WebResponse 跨域访问实例代码

.Net连接Oracle数据库的实现代码

精品推荐
分类导航