首先,是一段javascript脚本:
复制代码 代码如下:
/**
*
*
* @param table_id 表格的id
* @param container_id 容器的id
* @param form_id 提交表单的id
* @param title 文件名
* @param rownumbers
*/
function getXlsFromTbl(table_id, container_id ,form_id, title, rownumbers) {
try {
var content = "";
if (table_id != null && table_id != "" && table_id != "null") {
<SPAN style="WHITE-SPACE: pre"> </SPAN>content = getTblData($('#' + table_id), $('#' + container_id), rownumbers);
}
if (content == "") {
alert("表格不存在");
return;
}
var fileName = getExcelFileName(title);
doFileExport($('#' + form_id), fileName, content);
}
catch (e) {
alert("导出异常:" + e.name + "->" + e.description + "!");
}
}
function getTblData(tableobj, containerobj, rownumbers) {
var outStr = "";
if (tableobj != null) {
var rowdata = tableobj.getRowData();
var Lenr = 1;
for (i = 0; i < Lenr; i++) {
//var Lenc = curTbl.rows(i).cells.length;
var th;
if (rownumbers == false) {
th = containerobj.find('TH:not(:first-child)');
}
else {
th = containerobj.find('TH');
}
th.each(function(index, element) {
var j = index + 1;
var content = $(element).text();
content = content.replace(/(^\s*)|(\s*$)/g, "");//去掉空格
outStr += content + ",";
});
outStr += "+nl+";
}
var tmp = "";
for (i = 0; i < rowdata.length; i++) {
var row = eval(rowdata[i]);
for (each in row) {
<SPAN style="WHITE-SPACE: pre"> </SPAN>var temp = $(row[each]).text();
<SPAN style="WHITE-SPACE: pre"> </SPAN>if($(row[each]).text() == null || $(row[each]).text() == ""){
<SPAN style="WHITE-SPACE: pre"> </SPAN>if(row[each].charAt(0) != '<')
<SPAN style="WHITE-SPACE: pre"> </SPAN>outStr += row[each] + ",";
<SPAN style="WHITE-SPACE: pre"> </SPAN>
<SPAN style="WHITE-SPACE: pre"> </SPAN>}
<SPAN style="WHITE-SPACE: pre"> </SPAN>else
<SPAN style="WHITE-SPACE: pre"> </SPAN>outStr += $(row[each]).text() + ",";
}
outStr += "+nl+";
}
}
else {
outStr = null;
alert(inTbl + " null!");
}
return outStr;
}
function getExcelFileName(title) {
var d = new Date();
var curYear = d.getYear();
var curMonth = "" + (d.getMonth() + 1);
var curDate = "" + d.getDate();
var curHour = "" + d.getHours();
var curMinute = "" + d.getMinutes();
var curSecond = "" + d.getSeconds();
if (curMonth.length == 1) {
curMonth = "0" + curMonth;
}
if (curDate.length == 1) {
curDate = "0" + curDate;
}
if (curHour.length == 1) {
curHour = "0" + curHour;
}
if (curMinute.length == 1) {
curMinute = "0" + curMinute;
}
if (curSecond.length == 1) {
curSecond = "0" + curSecond;
}
var fileName = title + "_" + curYear + curMonth + curDate + "_"
+ curHour + curMinute + curSecond + ".csv";
return fileName;
}
function doFileExport(formobj, filename, content) {
<SPAN style="WHITE-SPACE: pre"> </SPAN>formobj.html("<input id='filename' name='filename' type='text' style='display: none'><input id='content' name='content' type='text' style='display: none'>");
$("#filename").val(filename);
$("#content").val(content);
formobj.submit();
}
接着是页面调用的javascript:
复制代码 代码如下:
<form id="download_form" method="post" target="_blank" action="downLoadTableDataAction">
复制代码 代码如下:
<div id="table_container">
<SPAN style="WHITE-SPACE: pre"> </SPAN><table id="keyword_detail"></table>
<SPAN style="WHITE-SPACE: pre"> </SPAN><div id="footer"></div>
</div>
复制代码 代码如下:
//下载
$('#download_file').click(function() {
getXlsFromTbl('keyword_detail', 'table_container' ,'download_form', '关键词详细数据', true)
});
jqgrid,表格数据
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?