导入:
复制代码 代码如下:
untitled page
导出:
复制代码 代码如下:
function automateexcel()
{
// start excel and get application object.
var oxl = new activexobject(excel.application);
oxl.visible = true;
// get a new workbook.
var owb = oxl.workbooks.add();
var osheet = owb.activesheet;
// add table headers going cell by cell.
osheet.cells(1, 1).value = first name;
osheet.cells(1, 2).value = last name;
osheet.cells(1, 3).value = full name;
osheet.cells(1, 4).value = salary;
// format a1:d1 as bold, vertical alignment = center.
osheet.range(a1, d1).font.bold = true;
osheet.range(a1, d1).verticalalignment = -4108; //xlvaligncenter
// create an array to set multiple values at once.
// fill a2:b6 with an array of values (from vbscript).
osheet.range(a2, b6).value = createnamesarray();
// fill c2:c6 with a relative formula (=a2 & & b2).
var orng = osheet.range(c2, c6);
orng.formula = =a2 & & b2;
// fill d2:d6 with a formula(=rand()*100000) and apply format.
orng = osheet.range(d2, d6);
orng.formula = =rand()*100000;
orng.numberformat = $0.00;
// autofit columns a:d.
orng = osheet.range(a1, d1);
orng.entirecolumn.autofit();
// manipulate a variable number of columns for quarterly sales data.
dispalyquarterlysales(osheet);
// make sure excel is visible and give the user control
// of excel's lifetime.
oxl.visible = true;
oxl.usercontrol = true;
}
将页面中指定表格的数据导入到excel中
编号
姓名
年龄
性别
0001
张三
22
女
0002
李四
23
男
复制代码 代码如下:
br>http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd>
web椤甸