请问如何在客户端创建excel文件。

franci007 2001-08-16 05:36:16
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<script language=vbscript>
sub fun()
Set exl=createobject("excel.application")
exl.application.visible=true
exl.Application.Workbooks.Add
exl.Application.cells(1,1).value="123"
end sub
</script>
</HEAD>
<BODY>

<P><INPUT id=button1 type=button value=Button name=button1 onclick="fun()"></P>

</BODY>
</HTML>

此页面在ID6.0的quickview中运行良好,单改到ie中就提示出错:
ActiveX部件不能创建对象:excel.application
请问要如何解决!谢谢!
...全文
145 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
蒋晟 2001-08-26
  • 打赏
  • 举报
回复
HOWTO: Display ASP Results Using Excel in IE with MIME Types
ID: Q199841


--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Visual InterDev, version 6.0
Microsoft Internet Information Server 4.0
Microsoft Excel for Windows

--------------------------------------------------------------------------------


SUMMARY
Instead of displaying your Web data in HTML tables, you can provide users with the option of displaying the data in Microsoft Excel. This article demonstrates how to create a Web page with tabular data obtained from Microsoft SQL Server, and render it in Excel inside the browser by associating the Web-page content with the MIME type in Excel.



MORE INFORMATION
To follow along with the steps and test the results, you need the following:



Microsoft Windows NT Server 4.0, SP3
Microsoft Internet Information Server (IIS), version 4.0
Microsoft SQL Server 6.5
Microsoft Excel 97
Step-by-Step Procedures
Create a System DSN called "pubs" using the ODBC Control-Panel applet. Set up the DSN to reference your local SQL Server, use SQL Server authentication, and use "pubs" as the default database. The default login ID to the pubs database is sa, with no password.


Use Notepad.exe to create a file called XlTest.asp in your IIS home directory (for example, inetpub\wwwroot), and add the following to it:



<%@ Language=VBScript %>
<%
'Change HTML header to specify Excel's MIME content type
Response.Buffer = TRUE
Response.ContentType = "application/vnd.ms-excel"
%>
<HTML>
<BODY>
Here is the info you requested.<p>
<%
' Create ADO Connection object
dim myConnection
set myConnection = CreateObject("ADODB.Connection")

' Open SQL Server Pubs database...
myConnection.Open "DSN=pubs;UID=sa"

' Get a recordset of info from Authors table...
sqlStr = "SELECT au_fname,au_lname,phone FROM authors"
set rsAuthors = myConnection.Execute(sqlStr)
%>
<!-- Our table which will be translated into an Excel spreadsheet -->
<TABLE WIDTH=75% BORDER=1 CELLSPACING=1 CELLPADDING=1>
<TR>
<TD><font size=+2>First Name</font></TD>
<TD><font size=+2>Last Name</font></TD>
<TD><font size=+2>Phone</font></TD>
</TR>
<!-- server-side loop adding Table entries -->
<% do while not rsAuthors.EOF %>
<TR>
<TD><%=rsAuthors("au_fname")%></TD>
<TD><%=rsAuthors("au_lname")%></TD>
<TD><%=rsAuthors("phone")%></TD>
</TR>
<% rsAuthors.MoveNext
loop
' Clean up
rsAuthors.Close
set rsAuthors = Nothing
myConnection.Close
set myConnection = Nothing
%>
</TABLE>
</BODY>
</HTML>



Save XlTest.asp, and then view it from a client browser. For example, http://MyServer/XlTest.asp (replace "MyServer" with the name of your server.)



If Microsoft Excel 97 is installed on the client computer, Microsoft Excel displays the data inside the browser.

(c) Microsoft Corporation 1999, All Rights Reserved. Contributions by Joe Crump, Microsoft Corporation.



Additional query words: activexdocument docobject kbGrpDSO

Keywords : kbADO kbASP kbExcel kbSQLServ kbVisID kbGrpDSO
Version : WINDOWS:6.0,97; winnt:4.0
Platform :
Issue type : kbhowto
Technology :


Last Reviewed: October 12, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.




--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.
S.F. 2001-08-26
  • 打赏
  • 举报
回复
调用activex ,不建立对象
lanying 2001-08-25
  • 打赏
  • 举报
回复
工具-〉Indernet 选项-〉高级
jediknight 2001-08-25
  • 打赏
  • 举报
回复
请问有没有方法使建立过程在后台运行,而不调出EXECL界面
franci007 2001-08-16
  • 打赏
  • 举报
回复
如何设置ie的安全性。
wyzegg 2001-08-16
  • 打赏
  • 举报
回复
首先确认机器上有没有EXCEL,其次确认IE的安全设置是否允许

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧