function exportToExcel (tableId)/read each cell in the table to Excel
{
try{
var curtbl = document.getElementById (tableId);
var oXL = new ActiveXObject ("Excel.Application");
Create an Ax object Excel
var owb = OXL.Workbooks.Add ();
Get Workbook Object
var osheet = Owb.activesheet;
var lenrow = curTbl.rows.length;
Get the number of rows in the table
for (i = 0; i < Lenrow; i++)
{
var lencol = curtbl.rows (i). Cells.length;
Get the number of columns per row
for (j = 0; J < Lencol; J + +)
{
Osheet.cells (i + 1, j + 1). Value = Curtbl.rows (i). Cells (j). innertext;
}
}
oXL.Visible = true;
Set Excel Visible Properties
}catch (e) {
if ((!+ '/v1 ')) {//ie browser
Alert ("Unable to start Excel, make sure you have excel!/n/n installed on your computer if you have Excel installed," + "adjust the security level of IE.) /n/n specific operations:/n/n "+" tools →internet options → security → custom level →activex controls and Plug-ins → initialize and execute scripts → enable → OK for ActiveX controls not marked for safe execution;
}else{
Alert ("Import to Excel" using IE browser!) "); Easy to set security level, limited to IE browser
}
}
}
function exportToExcel (tableId)/read each cell in the table to Excel
{
try{
var curtbl = document.getElementById (tableId);
var oXL = new ActiveXObject ("Excel.Application");
Create an Ax object Excel
var owb = OXL.Workbooks.Add ();
Get Workbook Object
var osheet = Owb.activesheet;
var lenrow = curTbl.rows.length;
Get the number of rows in the table
for (i = 0; i < Lenrow; i++)
{
var lencol = curtbl.rows (i). Cells.length;
Get the number of columns per row
for (j = 0; J < Lencol; J + +)
{
Osheet.cells (i + 1, j + 1). Value = Curtbl.rows (i). Cells (j). innertext;
}
}
oXL.Visible = true;
Set Excel Visible Properties
}catch (e) {
if ((!+ '/v1 ')) {//ie browser
Alert ("Unable to start Excel, make sure you have excel!/n/n installed on your computer if you have Excel installed," + "adjust the security level of IE.) /n/n specific operations:/n/n "+" tools →internet options → security → custom level →activex controls and Plug-ins → initialize and execute scripts → enable → OK for ActiveX controls not marked for safe execution; www.th7.cn
}else{
Alert ("Import to Excel" using IE browser!) "); Easy to set security level, limited to IE browser
}
}
}