Grid 导出Excel asp.net Grid 导出Excel实现程序代码

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Grid 导出Excel asp.net Grid 导出Excel实现程序代码

  2021-03-19 我要评论
想了解asp.net Grid 导出Excel实现程序代码的相关内容吗,在本文为您仔细讲解Grid 导出Excel的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Grid,Excel,下面大家一起来学习吧。
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 名字'
}
]
}
]

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们