Home >Web Front-end >JS Tutorial >A simple example of Js exporting table contents to Excel_javascript skills
function ExportToExcel(tableId) //Read each cell in the table into EXCEL
{
try{
var curTbl = document.getElementById(tableId);
var oXL = new ActiveXObject ("Excel.Application");
et;
var lenRow = curTbl.rows.length;
//Get the number of table rows
for (i = 0; i < lenRow; i )
{
var lenCol = curTbl .rows(i).cells.length;
oSheet.Cells(i 1 , j 1).value = curTbl.rows(i).cells(j).innerText;
//Set excel visible attributes
}catch(e){
nIf Excel is already installed," "Please adjust the security level of IE. /n/nSpecific operation: /n/n" "Tools → Internet Options → Security → Custom Level → ActiveX Controls and Plug-ins → Mark Not as OK. The ActiveX control of the security execution script initializes and executes the script → enable → determine "); "); // Conveniently set the security level, limited to IE browser