【JS】打印Excel——ActiveX控件
1 function viewToExcel(){ 2 var filepath = "f:\\PrinterExcel.xls"; 3 var xlApp; 4 var xlBook; 5 var xlSheet; 6 try { 7 xlApp = new ActiveXObject("Excel.Application"); 8 } 9 catch (e) { 10 alert("请调整IE安全选项"); 11 return; 12 } 13 xlBook = xlApp.Workbooks.Open(filepath); 14 15 xlSheet = xlBook.ActiveSheet; 16 xlSheet.Cells(1,1).value="新乡"; 17 xlSheet.Cells(5,2).value="郑斌"; 18 xlSheet.Cells(3,5).value="2015"; 19 xlSheet.Cells(3,7).value="9"; 20 xlSheet.Cells(3,8).value="27"; 21 xlSheet.Cells(3,17).value="17408"; 22 xlSheet.Cells(11,13).value="王泰隆"; 23 24 alert("1"); 25 xlBook.PrintOut; 26 xlBook.Close(true); 27 }
梦想要一步步来!