如何用js或者vbscript之类的,调用excel里面的控件的事件,或者里面的VBA函数,求助,紧急,谢谢!

解决方案 »

  1.   

    客户端装有office的话,用第三方控件,有免费的 http://www.dianju.com.cn/pc/products-weboffice.php
      

  2.   

    这是一个打印程序 , mini版的,阅读可能有点累。多次出现■,是为了更新进度条。
    function exportPageToExcel(but){try{oExcel=new ActiveXObject('Excel.Application');oExcel.Visible=false;var iWidth=400;var iHeight=120;var iTop=(screen.availHeight-50-iHeight)/2;var iLeft=(screen.availWidth-10-iWidth)/2;var w=open('', 'Speed','height=120, width=400, top='+iTop+', left='+iLeft+', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');w.document.write ('<br>正在进行数据处理,请稍等<br><br><font color=red>');w.document.write('■');but.blur();oExcel.UserControl=false;oExcel.Caption='河南省XXXXXXXX监考统计打印系统,设计:风云';w.document.write('■');oBook=oExcel.Workbooks.Add;oSheet=oBook.Worksheets(1);w.document.write('■');document.execCommand('selectAll');document.execCommand('copy');document.execCommand('unselect');w.document.write('■');oSheet.Paste();w.document.write('■');oSheet.Cells.Font.Size=12;oSheet.Rows.RowHeight=24;w.document.write('■');oSheet.Cells(1)='河南省XXXXXX监考统计系统';oSheet.Cells(1).Font.Size=16;oSheet.Cells(1).Font.Bold=true;w.document.write('■');oSheet.Cells(1).RowHeight=40;oSheet.Cells(1).Font.ColorIndex=3;oSheet.Cells(1).HorizontalAlignment=-4108;w.document.write('■');oSheet.Cells(2,1)='设计:风云 2007/9/21';w.document.write('■');oSheet.Cells(2,1).Hyperlinks.Delete();oSheet.Cells(2,1).Font.Size=9;oSheet.Cells(2,1).RowHeight=20;w.document.write('■');oSheet.Cells(2,1).HorizontalAlignment=-4152;oSheet.Rows(oSheet.UsedRange.Rows.Count).Delete();w.document.write('■');oSheet.Cells(3,5)='签 名';oSheet.Cells(3,5).Font.Bold=true;oSheet.Cells(3,5).HorizontalAlignment=-4108;w.document.write('■');oSheet.Columns(1).ColumnWidth=8;oSheet.Columns(2).ColumnWidth=12;w.document.write('■');oSheet.Columns(3).ColumnWidth=14;oSheet.Columns(4).ColumnWidth=12;oSheet.Columns(5).ColumnWidth=20;w.document.write('■');rs=oSheet.UsedRange.Rows.Count;oSheet.Range('A3:E3').Interior.ColorIndex=35;w.document.write('■');oSheet.UsedRange.Offset(rs-1,0).Resize(1,5).Interior.ColorIndex=35;oSheet.UsedRange.Offset(2,0).Resize(rs-2,5).Select();w.document.write('■');oExcel.Selection.Borders.LineStyle=1;oExcel.Selection.Borders.Weight=-4138;oExcel.Selection.Borders.Color=255;w.document.write('■');oExcel.Selection.Borders(11).LineStyle=1;oExcel.Selection.Borders(11).Weight=1;oExcel.Selection.Borders(11).Color=255;w.document.write('■');oExcel.Selection.Borders(12).LineStyle=1;oExcel.Selection.Borders(12).Weight=1;oExcel.Selection.Borders(12).Color=255;w.document.write('■');oSheet.PageSetup.PrintTitleRows='$1:$3';w.document.write('■');oSheet.PageSetup.CenterHorizontally=true;oSheet.PageSetup.BlackAndWhite=true;oSheet.PageSetup.Zoom=false;w.document.write('■');oSheet.PageSetup.FitToPagesWide=1;oSheet.PageSetup.FitToPagesTall=20;w.document.write('■</font>');w.close();try{oExcel.Visible=true;oBook.PrintPreview();oExcel.Visible=false;}catch(e){oExcel.Visible=false;alert('No printer error!');}oBook.Close(savechanges=false);oExcel.Quit();oExcel=null;oBook=null;oSheet=null;}catch(e){alert('\n要正常打印,请确保:\n\n 1、安装Excel应用程序;\n\n 2、安装打印机及相应驱动程序;\n\n 3、将www.zzslxx.com添加为受信任的站点。');}}