var oexcel = new ActiveXObject ("Excel.Application"); Create an Excel object
var owork =oexcel.workbooks.add (); Create a new Excel workbook
var osheet =owork.activesheet; Specify the worksheet to write to the active sheet
var table =document.all.table1; Specifies the ID of the data source to write to
var myrow =table.rows.length; Number of rows to fetch data source
var MyCell =table.rows (0). Cells.length; Number of data source columns taken
for (i=0;i<myrow;i++) {//write lines in Excel
for (j=0;j<mycell;j++) {//write columns in Excel
Defining formats
if ((i==0) | (i==myrow-1)) {
Osheet.cells (i+1,j+1). Font.Bold =true; Bold
Osheet.cells (i+1,j+1). Font.Size = 12; Font size
}else{
Osheet.cells (i+1,j+1). Font.Bold =false;
Osheet.cells (i+1,j+1). Font.Size = 10; Font size
}
Osheet.cells (i+1,j+1). Value =table.rows (i). Cells (j). InnerText; Write values to cells
}
}
oExcel.Visible = true;
oExcel.UserControl = true;
Import data into an Excel table