<script type="text/javascript" > var fso = new ActiveXObject("Scripting.FileSystemObject") fso.CreateFolder ("C:\\Bonus");//在C盘创建一个文件夹 fso.DeleteFolder ("C:\\Bonus");// 删除创建的文件夹 fso.CopyFile("c:\\temp\\11.bmp","c:\\Bonus\\22.bmp");//复制文件 // 创建新文件 var tf = fso.CreateTextFile("c:\\testfile.txt", true); tf.WriteLine("Testing 1, 2, 3.") ; // 填写数据,并增加换行符 tf.WriteBlankLines(3) ; // 增加个空行 tf.Write ("This is a test."); // 填写一行,不带换行符 tf.Close(); // 关闭文件 // 打开文件 var ForReading=1; var ts = fso.OpenTextFile("c:\\testfile.txt", ForReading); s = ts.ReadLine(); // 读取文件一行内容到字符串 alert("File contents = '" + s + "'"); // 显示字符串信息 ts.Close(); // 关闭文件 </script> <script language="javascript"> var ExcelApp = new ActiveXObject("Excel.Application"); //启动创建对象的应用程序EXCEL var ExcelSheet = new ActiveXObject("Excel.Sheet"); //创建EXCEL工作表 ExcelSheet.Application.Visible = true; // 使Excel窗口可见 // 将一些文本放置到表格的第一格中。 ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1"; // 保存EXCEL到C:\TEST.XLS。 ExcelSheet.SaveAs("C:\\TEST1.XLS"); //用Quit 方法关闭Excel。 ExcelApp.Quit(); //可以找到C:\TEST1.XLS文件,检查其正确性 </script> <script language="javascript"> //启动EXCEL var ExcelApp = new ActiveXObject("Excel.Application"); ExcelApp.Visible = true; //使EXCEL窗口可见 ExcelApp.WorkBooks.Open("c:\\TEST.xls"); var objExcelBook=ExcelApp.ActiveWorkBook; var objExcelSheets=objExcelBook.Worksheets; var objExcelSheet=objExcelBook.Sheets(1); //指定当前工作区为Sheet2 //此处为对excel单元格进行填写数据的语句 objExcelSheet.Range("B2:k2").Value=Array("Week1","Week2","Week3","Week4","Week5","Week6","Week7"); objExcelSheet.Range("B3:k3").Value=Array("67","87","5","9","7","45","45","54","54","10"); objExcelSheet.Range("B4:k4").Value=Array("10","10","8","27","33","37","50","54","10","10"); objExcelSheet.Range("B5:k5").Value=Array("23","3","86","64","60","18","5","1","36","80"); objExcelSheet.Cells(3,1).Value="InternetExplorer"; objExcelSheet.Cells(4,1).Value="Netscape"; objExcelSheet.Cells(5,1).Value="Other"; objExcelSheet.SaveAs("C:\\TEST2.XLS"); //保存到C:\TEST2.XLS ExcelApp.Quit(); //退出EXCEL </script> <script language="javascript"> WordApp = new ActiveXObject("Word.Application"); //启动Word WordApp.Application.Visible = true; //使Word窗口可见 var mydoc=WordApp.Documents.Add("",0,1); //新建一个文档 WordApp.ActiveWindow.ActivePane.View.Type=3; //Word视图模式为页面 WordApp.Selection.TypeText("测试案例"); //输入字符串 WordApp.Selection.HomeKey (5,1); //光标移到行首 WordApp.Selection.Font.Bold = 9999998 ; //wdToggle WordApp.Selection.WholeStory(); //选中整个文档内容 mydoc.SaveAs("c:\\test.doc"); //存盘到c:\test.doc for(i=WordApp.Documents.Count;i>0;i--){ //关闭所有打开的WORD文档 WordApp.Documents(i).Close(0); } WordApp.Application.quit(); //退出Word </script>