ActiveXObject示例

来源:互联网 发布:解决问题的思路 知乎 编辑:程序博客网 时间:2024/05/02 16:48
<script>
excelApp = new ActiveXObject("Excel.Application");
excelSheet = new ActiveXObject("Excel.Sheet");
// 使 Excel 通过 Application 对象可见。
excelSheet.Application.Visible = true;
// 将一些文本放置到表格中。
excelSheet.ActiveSheet.Cells(1,1).Value = "这是第一行第一列";
excelSheet.ActiveSheet.Cells(2,1).Value = "这是第二行第一列";
excelSheet.ActiveSheet.Cells(2,2).Value = "这是第二行第二列";
// 保存表格。
excelSheet.SaveAs("C:/excelTest.xls");
// 用 Application 对象用 Quit 方法关闭 Excel。
excelSheet.Application.Quit();
</script>