接受参数:Table的 ID
function tableToExcel(tblName)
{
function String.prototype.Trim() {return this.replace(/(^\s*)|(\s*$)/g,"");}
try
{
var e = document.getElementById(tblName);
var s = ""
for (var j=0; j<e.rows.length; j++)
{
if (e.rows[j].style.display != "none")
{
for (var i=1; i<e.rows[j].cells.length; i++)
{
if (e.rows[j].cells[i].style.display != "none")
s += e.rows[j].cells[i].innerText.Trim() +"\t";
}
s += "\r\n";
}
}
var xlsWindow = window.open("","_blank","width=100,height=100");
xlsWindow.document.write(s);
xlsWindow.document.execCommand('Saveas',true,'%homeDrive%\\Data.xls');
xlsWindow.close();
}
catch(e)
{}
}
{
function String.prototype.Trim() {return this.replace(/(^\s*)|(\s*$)/g,"");}
try
{
var e = document.getElementById(tblName);
var s = ""
for (var j=0; j<e.rows.length; j++)
{
if (e.rows[j].style.display != "none")
{
for (var i=1; i<e.rows[j].cells.length; i++)
{
if (e.rows[j].cells[i].style.display != "none")
s += e.rows[j].cells[i].innerText.Trim() +"\t";
}
s += "\r\n";
}
}
var xlsWindow = window.open("","_blank","width=100,height=100");
xlsWindow.document.write(s);
xlsWindow.document.execCommand('Saveas',true,'%homeDrive%\\Data.xls');
xlsWindow.close();
}
catch(e)
{}
}