打印模板通过EXCEL设置好,模板的名称是 110printmode.XLS ,里面有需要打印的内容现在想通过点打印按钮,实现另存,预览和打印高手指教
最好有现成的代码

解决方案 »

  1.   

    这种情况最好还是用Excel自己的打印,预览等功能,web端就做一个在线编辑功能即可
      

  2.   

    这种情况最好还是用Excel自己的打印,预览等功能,web端就做一个在线编辑功能即可
    有具体的代码吗
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gbk">
    <title>Insert title here</title>
    <script language="javascript" > 
    function print(){
    var excelApp; 
    var excelWorkBook; 
    var excelSheet; 
    var fso;
    var f;
    var f2;
    var strSource = "C:\\Program Files\\ZXSACSMainFrame\\110printmode.XLS";
    var strDestination= "C:\\" + "temp.xls";try{
    excelApp = new ActiveXObject("Excel.Application");
    fso   =   new ActiveXObject("Scripting.FileSystemObject");
    }catch(e){
    alert("无法启动Excel!\n\n" +e.message + "\n\n如果您确信您的电脑中已经安装了Excel,"+"那么请调整IE的安全级别。\n\n具体操作:\n\n"+"工具 → Internet选项 → 安全 → 自定义级别 → 对没有标记为安全的ActiveX进行初始化和脚本运行 → 启用");
    return;
    }
    try{
    f = fso.GetFile(strSource);    
    f.Copy(strDestination);
    excelWorkBook = excelApp.Workbooks.open(strDestination); 
    excelWorkBook.worksheets(1).select(); 
    excelSheet = excelWorkBook.ActiveSheet; //WorkSheets("sheet1") 
    excelSheet.Cells(1,2).value = 22;//给属性赋值cell的值 
    //alert(excelSheet.Cells(1,1).value);//读取cell的值
    //excelSheet.usedrange.rows.count;//使用的行数 
    //excelWorkBook.Worksheets.count;//得到sheet的个数  //实现保存和打印预览
    //excelWorkBook.saveAs(strDestination);//保存的目录 excelWorkBook.save;//保存的目录
    excelWorkBook.PrintOut;
    excelSheet=null;
    excelWorkBook.Close;
    //删除备份文件
    f2=fso.GetFile(strDestination); 
    f2.Delete();  
    excelApp.Quit(); //结束EXCEL进程,退出完成
    excelApp=null; }catch(e){ 
    alert(" ;;;; excelWorkBook = " + excelWorkBook + " ;;;;; excelApp=  " +excelApp)
    if(excelSheet !=null || excelSheet!=undefined){ 
    excelSheet =null; 

    if(excelWorkBook != null || excelWorkBook!=undefined){ 
    excelWorkBook.close(savechanges=false); 

    if(excelApp != null || excelApp!=undefined){ 
    excelApp.Application.Quit(); 



    </script >
    </head>
    <body>
    <input type="submit" name ="按钮" value="submit" onclick="print();"/>
    </body>
    </html>备注
    excelApp.Quit(); //结束EXCEL进程,退出完成
    excelApp=null;
    无法结束生成的EXCEL进程
    高手帮助
      

  4.   

    浏览器被限制不能百度和GOOGL有人知道在JS中如何结束一个进程吗????