js导出gridview到excel
来源:互联网 发布:windows程序设计第5版 编辑:程序博客网 时间:2024/06/05 13:27
<html>
<head>
<script type="text/javascript">
var tableToExcel = (function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(table, name) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }
window.location.href = uri + base64(format(template, ctx))
}
})()
</script>
</head>
<body>
<h1>tableToExcel Demo</h1>
<p>Exporting the W3C Example Table</p>
<input type="button" onclick="tableToExcel('GridViewBoiler', 'W3C Example Table')" value="Export to Excel">
<table cellspacing="0" cellpadding="4" rules="all" border="1" id="Table1" style="color:#333333;width:100%;border-collapse:collapse;">
<tbody><tr style="color:White;background-color:#507CD1;font-weight:bold;">
<th scope="col">序号</th><th scope="col">参数描述</th><th scope="col">--望亭发电有限公司--#11机组--锅炉本体试验--2015-02-09 14:40:53--</th>
</tr><tr style="background-color:#EFF3FB;">
<td align="center">1</td><td align="left">入炉煤收到基低位发热量(KJ/Kg)</td><td>19600.0000</td>
</tr><tr style="background-color:White;">
<td align="center">2</td><td align="left">入炉煤收到基灰分(%)</td><td>23.6000</td>
</tr><tr style="background-color:#EFF3FB;">
<td align="center">3</td><td align="left">入炉煤收到基水分(%)</td><td>4.1800</td>
</tr><tr style="background-color:White;">
<td align="center">4</td><td align="left">入炉煤收到基碳含量(%)</td><td>57.4900</td>
</tr><tr style="background-color:#EFF3FB;">
<td align="center">5</td><td align="left">入炉煤收到基氢含量(%)</td><td>3.6500</td>
</tr><tr style="background-color:White;">
<td align="center">6</td><td align="left">入炉煤收到基氧含量(%)</td><td>9.9500</td>
</tr><tr style="background-color:White;">
<td align="center">20</td><td align="left">换算至设计送风温度时的排烟温度(%)</td><td>122.0239</td>
</tr><tr style="background-color:#EFF3FB;">
<td align="center">21</td><td align="left">修正后锅炉热效率(%)</td><td>91.2669</td>
</tr>
</tbody></table>
</body>
<head>
<script type="text/javascript">
var tableToExcel = (function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(table, name) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }
window.location.href = uri + base64(format(template, ctx))
}
})()
</script>
</head>
<body>
<h1>tableToExcel Demo</h1>
<p>Exporting the W3C Example Table</p>
<input type="button" onclick="tableToExcel('GridViewBoiler', 'W3C Example Table')" value="Export to Excel">
<table cellspacing="0" cellpadding="4" rules="all" border="1" id="Table1" style="color:#333333;width:100%;border-collapse:collapse;">
<tbody><tr style="color:White;background-color:#507CD1;font-weight:bold;">
<th scope="col">序号</th><th scope="col">参数描述</th><th scope="col">--望亭发电有限公司--#11机组--锅炉本体试验--2015-02-09 14:40:53--</th>
</tr><tr style="background-color:#EFF3FB;">
<td align="center">1</td><td align="left">入炉煤收到基低位发热量(KJ/Kg)</td><td>19600.0000</td>
</tr><tr style="background-color:White;">
<td align="center">2</td><td align="left">入炉煤收到基灰分(%)</td><td>23.6000</td>
</tr><tr style="background-color:#EFF3FB;">
<td align="center">3</td><td align="left">入炉煤收到基水分(%)</td><td>4.1800</td>
</tr><tr style="background-color:White;">
<td align="center">4</td><td align="left">入炉煤收到基碳含量(%)</td><td>57.4900</td>
</tr><tr style="background-color:#EFF3FB;">
<td align="center">5</td><td align="left">入炉煤收到基氢含量(%)</td><td>3.6500</td>
</tr><tr style="background-color:White;">
<td align="center">6</td><td align="left">入炉煤收到基氧含量(%)</td><td>9.9500</td>
</tr><tr style="background-color:White;">
<td align="center">20</td><td align="left">换算至设计送风温度时的排烟温度(%)</td><td>122.0239</td>
</tr><tr style="background-color:#EFF3FB;">
<td align="center">21</td><td align="left">修正后锅炉热效率(%)</td><td>91.2669</td>
</tr>
</tbody></table>
</body>
</html>
效果图:
0 0
- js导出gridview到excel
- GridView导出到Excel
- GridView导出到Excel
- GridView导出到Excel
- GridView导出到Excel
- gridview 导出到excel
- 导出GridView到Excel
- 导出GridView到Excel
- GridView导出到Excel
- GridView导出到Excel
- GridView 导出到EXCEL
- GridView导出到Excel
- GridView 导出到 Excel
- Gridview导出到excel
- GridView 导出到excel
- 导出Gridview到excel
- GridView导出到Excel
- GridView导出到Excel
- DBMS_STATS.GATHER_TABLE_STATS解析
- Effective C++读书笔记(条款18-23)
- 《Cocos2d学习之路》九、数据存储的几种方式和基本使用
- java--多态3
- !!!Adb 抓不住Genymotion的解决方法
- js导出gridview到excel
- 构建一个Scala程序
- java读写锁ReentrantReadWriteLock实现多并发单利模式
- <CSS设计指南> 学习总结 -- 第一二章
- QT编译出错解决 libQtCore.so: undefined reference to `QInotifyFileSystemWatcherEngine::create()'
- python学习笔记
- <CSS设计指南> 学习总结 -- 第三章
- Python学习笔记 知识点
- 1332: addreviate--中级