⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 如何在asp中用javascript打开excel的模板文件.htm

📁 较为详细的介绍了asp自定义的各种函数,方便asp的各种开发.
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0055)http://www.51base.com/article/view_article.asp?id=78155 -->
<HTML lang=zh-cn><HEAD><TITLE>NB联盟</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type><LINK 
href="NB联盟34.files/style.css" rel=stylesheet>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR></HEAD>
<BODY><!-- start page body -->
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 class=td id=position 
width=773>
  <TBODY>
  <TR>
    <TD class=shadow colSpan=2 height=20 width=262>&nbsp;&nbsp;<A 
      href="http://www.51base.com/"><IMG border=0 
      src="NB联盟34.files/logo1.gif"></A> </TD>
    <TD align=right width=505>
      <P align=left></P></TD></TR></TBODY></TABLE>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 id=main width=770>
  <TBODY>
  <TR>
    <TD class=tdlbr vAlign=top>
      <TABLE align=center border=0 cellPadding=0 cellSpacing=0 id=welcome 
      style="TABLE-LAYOUT: fixed" width="98%">
        <TBODY>
        <TR>
          <TD style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" 
            vAlign=top><FONT color=red><B>文章标题</B></FONT><FONT color=red><B>: 
            别人解决不了,只好请版主tonnycncn帮忙!!!问题是如何在ASP中用JAVASCRIPT打开EXCEL的模板文件?附源代码如下 
            </B></FONT>
            <HR noShade SIZE=1>
            <BR>源代码为(大虾提供的,在此表示感谢!!) &nbsp; &nbsp; &nbsp;<BR>function &nbsp; 
            &nbsp;AutomateExcel() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<BR>{ &nbsp; &nbsp; 
            &nbsp;<BR>&lt;!- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;<BR>&nbsp;var &nbsp; &nbsp;oXL &nbsp; &nbsp;= &nbsp; &nbsp;new 
            &nbsp; &nbsp;ActiveXObject("Excel.Application"); &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var &nbsp; &nbsp;oWB &nbsp; 
            &nbsp;= &nbsp; &nbsp;oXL.Workbooks.open("d:\\yzq.xlt"); &nbsp; 
            &nbsp; &nbsp;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp;var &nbsp; &nbsp;oSheet &nbsp; &nbsp;= 
            &nbsp; &nbsp;oWB.ActiveSheet; &nbsp; &nbsp; &nbsp;<BR>&nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;oXL.Visible &nbsp; &nbsp;= &nbsp; &nbsp;true; &nbsp; &nbsp; 
            &nbsp;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp;oXL.UserControl &nbsp; &nbsp;= &nbsp; 
            &nbsp;true; &nbsp; &nbsp; &nbsp;<BR>} &nbsp; &nbsp; 
            &nbsp;<BR>//--&gt; &nbsp; &nbsp; &nbsp;<BR>&lt;/SCRIPT&gt; &nbsp; 
            &nbsp; &nbsp;<BR>&nbsp; &nbsp;<BR>在IE中运行时,MS 
            &nbsp;EXCEL能正常运行,但就是打不开YZQ.XLT模板文件,显示的错误是MS 
            &nbsp;EXCEL找不到d:\yzq.xlt文件,但该文件确实存在。但如果是新增一个BOOK1.XLS文件,运行正常,源代码将oXL.Workbooks.open("d:\\yzq.xlt");改为oXL.Workbooks.add();即可。 
            &nbsp;<BR>&nbsp;<BR>--------------------------------------------------------------- 
            &nbsp;<BR>&nbsp;<BR>不好意思,现在才看到。给你一段代码吧。你应该可以看出区别吧。 
            &nbsp;<BR>&lt;script &nbsp;language="JavaScript"&gt; 
            &nbsp;<BR>&nbsp; &nbsp;function &nbsp;startExcel(strFile) 
            &nbsp;<BR>&nbsp; &nbsp;{ &nbsp;<BR>&nbsp; &nbsp; &nbsp; &nbsp;var 
            &nbsp;myApp &nbsp;= &nbsp;new 
            &nbsp;ActiveXObject("Excel.Application"); &nbsp;<BR>&nbsp; &nbsp; 
            &nbsp; &nbsp;if &nbsp;(myApp &nbsp;!= &nbsp;null) &nbsp;<BR>&nbsp; 
            &nbsp; &nbsp; &nbsp;{ &nbsp;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;myApp.Visible &nbsp;= &nbsp;true; &nbsp;<BR>&nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp;myApp.Workbooks.Open(strFile); 
            &nbsp;<BR>&nbsp; &nbsp; &nbsp; &nbsp;} &nbsp;<BR>&nbsp; &nbsp;} 
            &nbsp;<BR>&lt;/script&gt; &nbsp;<BR>You &nbsp;can &nbsp;now 
            &nbsp;start &nbsp;Excel &nbsp;with &nbsp;a &nbsp;hyperlink: 
            &nbsp;<BR>&lt;a 
            &nbsp;href="javascript:startExcel('http://yoursite/test.xls')"&gt;Test.xls&lt;/a&gt;. 
            &nbsp;<BR>As &nbsp;Excel &nbsp;is &nbsp;running &nbsp;locally, 
            &nbsp;mind &nbsp;to &nbsp;feed &nbsp;a &nbsp;full &nbsp;URL &nbsp;as 
            &nbsp;a &nbsp;parameter &nbsp;if &nbsp;you &nbsp;want &nbsp;to 
            &nbsp;open &nbsp;a &nbsp;web &nbsp;document. &nbsp; 
        &nbsp;<BR><BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE align=center border=0 cellPadding=2 cellSpacing=0 id=footer width=770>
  <TBODY>
  <TR>
    <TD align=middle class=tdt>
      <P align=center></P></TD></TR></TBODY></TABLE><BR></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -