js的不会,觉得VB的很好
etb是table的ID,还需要画成什么样子可以参考EXCEL里的宏 on error resume next
Set xlApp = CreateObject("EXCEL.APPLICATION")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
with xlSheet
.Name = bnum
rows=etb.rows.length-1
cols=etb.rows(0).cells.length-1
for x = 0 to rows
for y = 0 to cols
x1=x+1
y1=y+1
.cells(x1,y1) = etb.rows(x).cells(y).innerText
next
next
columns="A:" & chr(65+cols)
.Columns(columns).EntireColumn.AutoFit
area="A1:" & chr(65+cols) & (rows+1)
with .Range(area)
.Borders(1).LineStyle = 1
.Borders(2).LineStyle = 1
.Borders(3).LineStyle = 1
.Borders(4).LineStyle = 1
end with
area="A1:" & chr(65+cols) & "1"
.Range(area).Interior.ColorIndex = 33
area="A2:" & chr(65+cols) & (rows+1)
.Range(area).Interior.ColorIndex = 34
end with
Set xlApp = Nothing
etb是table的ID,还需要画成什么样子可以参考EXCEL里的宏 on error resume next
Set xlApp = CreateObject("EXCEL.APPLICATION")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
with xlSheet
.Name = bnum
rows=etb.rows.length-1
cols=etb.rows(0).cells.length-1
for x = 0 to rows
for y = 0 to cols
x1=x+1
y1=y+1
.cells(x1,y1) = etb.rows(x).cells(y).innerText
next
next
columns="A:" & chr(65+cols)
.Columns(columns).EntireColumn.AutoFit
area="A1:" & chr(65+cols) & (rows+1)
with .Range(area)
.Borders(1).LineStyle = 1
.Borders(2).LineStyle = 1
.Borders(3).LineStyle = 1
.Borders(4).LineStyle = 1
end with
area="A1:" & chr(65+cols) & "1"
.Range(area).Interior.ColorIndex = 33
area="A2:" & chr(65+cols) & (rows+1)
.Range(area).Interior.ColorIndex = 34
end with
Set xlApp = Nothing
function AutomateExcel(objTable)
{
//Start Excel and get Application object.
var oXL = new ActiveXObject("Excel.Application");
//Get a new workbook.
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
var table = objTable;
var hang = table.rows.length; var lie = table.rows(0).cells.length; // Add table headers going cell by cell.
for (i=0;i<hang;i++){
for (j=0;j<lie;j++) {
oSheet.Cells(i+1,j+1).value = table.rows(i).cells(j).innerText; }
}
oXL.Visible = true;
oXL.UserControl = true;
}