哪里可以使用这些组件?
既然Office Web Components都是COM控件,您会很自然的希望它们能够在任何自称是COM控件容器的环境中工作。然而,理论和现实不总是一致的,尤其在软件世界里。微软公司创造了许多能够包含控件的环境(我们小组脱口就能说出了16个),而别的公司创造了许多其它的环境。
为了避免Office的测试小组发狂,我们针对不同的容器,进行不同的级别的Office Web Components测试。首先,我们挑选出那些我们认为人们使用的最多的容器,进行了充分的测试。然后,我们在不常使用的容器中进行了基本的和特别的测试。最后,我们将一些容器组织起来,形成了一个”没有经过正式的测试,但是当使用时不会产生灾难性后果”的范围。表1-1显示了这个范围中的容器。
表 1-1. 经过测试的容器.
Container Test Coverage Microsoft Internet Explorer 5.0 Full Microsoft Internet Explorer 4.01 Full Microsoft Internet Explorer 3.x Not supported Microsoft Visual Basic 6.0 Full Microsoft Visual Basic 5.0 Basic Microsoft Visual InterDev Basic Microsoft Access Forms Basic Microsoft Office UserForms Basic Microsoft FrontPage 99 Full Microsoft FrontPage 98 Basic Microsoft Access 2000 Data Access Page Designer Full Microsoft Script Editor Full Microsoft Word 2000 Basic Microsoft Excel 2000 Basic Microsoft PowerPoint 2000 Basic Microsoft Outlook 2000 Basic Microsoft Visual C++/MFC Projects None Microsoft Visual J++ None
还有,要注意在不同的容器中,控件的设计时行为很不相同。因为Office Web Components是相当复杂的控件,常常需要在控件内部选择元素(例如电子表格中的单元,数据透视报表中的透视字段,或图表中的一系列数据点),以及格式化或处理这些元素。为了能够实现这个功能,在允许控件界面激活的容器中,控件会界面激活,这意味着这些控件会响应鼠标和键盘事件。在设计模式中针对控件所做的任何修改,都会在运行期间重载控件时和文档或窗体一起被保留,这就使得控件在被重置时显得和您保存它们时完全一样。一些容器在您点击控件时立刻使控件界面激活。而另一些容器则要求双击控件。还有其它的一些容器要求您通过两次单击来激活这些控件。这些行为完全由容器所决定。因此请参考容器的文档,以了解容器如何在设计阶段处理COM控件。
请注意上述这些并不会影响控件运行期间的行为。在运行期间,所有的容器在加载了控件之后就会使控件界面激活。但是一些环境,例如Office文档,因为您总是在编辑当前加载的文档,所以永远也不会进入运行状态。而Internet Exlporer,Visual Basic,Visual C++,Access Forms和Office用户界面都具有运行时模式,期间控件会立刻被激活。
数据存取页和Internet Explorer 5
如果您阅读任何Access2000的文档,您很可能看到一些声明,告诉您只能在Internet Explorer5或更高版本中浏览数据存取页。虽然这是真的,但是这个声明一般并不适用于Office Web Components。这些组件可以在Internet Explorer 4.01及以上版本中使用,然而它们不能在任何较早版本中使用(4.0,3.x,2.x等等)。这个版本要求也适用于任何使用Excel2000创建的交互内容(创建过程使用Office Web Components),也适用于使用这些组件开发出的定制解决方案。数据存取页需要Internet Explorer5中一些特殊的特性,这就是为什么它们只能在这个环境中运行。然而,Office Web Components本身可以很好的在上面所列的那些经过测试的容器中使用。
在服务器上使用Office Web Components
前文提到过,Office Web Components即能够以控件的形式驻留在窗体,文档或网页中,也可以以无用户界面的对象的形式驻留在内存中。每个控件都提供一个属性或者方法以返回控件当前内容的静态表现形式。图表和数据透视表控件可以创建它们内容的GIF图形,而电子表格控件可以返回一个HTML的表格片断或者一个完整地页面,这个片断或者页面可以在任何与HTML3.2兼容的浏览器中显示。所有这些都意味这您可以在web服务器上使用这些控件,实现服务器端的图表图形和数据透视报表的生成,或实现服务器端的电子表格模型重算功能。我会在本书第二部分演示一些这类技巧。
除了讨论如何在服务器上使用这些控件之外,我们也会在本书后部考察许多更精细的问题,例如性能,可伸缩性和可靠性。
部 署
基于web的解决方案最具吸引力的方面之一就是不需要应用程序的显示安装。需要做的事情要么是以脚本的形式在页面中编程,要么是以applets或者com控件的形式自动下载。Office Web Components通过使用Internet Explorer的codebase特征,可以实现无需安装的部署和自动的更新机制。这些组件也包括一个成熟的web安装工具,使得下载的过程十分有意思。还有,OWC在技术上并不依赖于Office 2000,因此它能够和Office97环境并存,也能在没有安装任何Office软件的机器上使用。
在第12章会涉及到关于部署任务的各方面,以及如何建立自动部署OWC的解决方案。
Netscape Navigator怎么样?
当我在讨论会和其它一些用户聚会上讲述Office Web Components时,总有人问这个问题:“这些组件可以在Netscape Navigator中运行吗?”答案是明确的“不行,”但是,这里有一些需要说明的地方。
Netscape Navigator 4.5本身并不支持COM控件,因此如果没有安装任何插件,Office Web Components甚至不能被Netscape navigaotor加载。然而,一个名为NCompass Labs的公司为Netscape Navigator开发了一个控件,使得Netscape Navigator可以在web页面中控制COM控件。那么,如果您安装了这个插件,您就能够在Netscape Navigator中使用这些组件了吗?答案是“看情况”,这里又有一些需要说明的。
您可能使用OWC建立许多包含了组件间通讯的解决方案――例如,绑定到一个数据透视表或者电子表格上的图表,或是绑定到页面上其它元素属性上的一个电子表格单元。这些解决方案需要Internet Explorer提供的功能的支持。而即使是安装了NCompass插件的Netscape Navigator也不能提供这些功能,因此这些解决方案完全不能在Netscape Navigator中工作。
使用单个的组件或是使用相互间不通讯的多个组件的解决方案,是可能在Netscape Navigator中成功运行的。然而,这是我们的测试小组没有研究的容器之一,因此我不能保证它会成功。
您应该还记得,无论如何,由服务器上的控件产生的静态内容可以在Netscape Navigator和Internet Explorer中显示。因此如果您的运行环境需要支持两个浏览器,您可能会对在web server上使用这些组件的方法以及展示了实现这些功能的技术的解决方案感兴趣。
附录:英文原文
Where Can You Use the Components?
Since the Office Web Components are COM controls, you'd naturally expect them to work in any environment that called itself a COM control container. However, theory and reality don't always match up, especially in the world of software. Microsoft makes many environments that can contain controls (16 that our team could recall off the top of our heads), and various other companies create many others.
To keep the Office test team from going mad, we tested the Office Web Components at different levels in different containers. First, we picked the containers we thought people would use most and performed full test passes on them. We then performed basic, ad hoc testing on the containers used less often. And finally, we grouped a few containers into the "not formally tested but doesn't cause a nuclear meltdown when tried" category. Table 1-1 shows which containers fell into what category.
Table 1-1. Tested containers.
Container Test Coverage Microsoft Internet Explorer 5.0 Full Microsoft Internet Explorer 4.01 Full Microsoft Internet Explorer 3.x Not supported Microsoft Visual Basic 6.0 Full Microsoft Visual Basic 5.0 Basic Microsoft Visual InterDev Basic Microsoft Access Forms Basic Microsoft Office UserForms Basic Microsoft FrontPage 99 Full Microsoft FrontPage 98 Basic Microsoft Access 2000 Data Access Page Designer Full Microsoft Script Editor Full Microsoft Word 2000 Basic Microsoft Excel 2000 Basic Microsoft PowerPoint 2000 Basic Microsoft Outlook 2000 Basic Microsoft Visual C++/MFC Projects None Microsoft Visual J++ None
Also note that the design-time activation of the controls varies quite a bit from container to container. Since the Office Web Components are fairly complex controls, it is often necessary to select elements within a control (such as a cell in a spreadsheet, a pivot field in a PivotTable report, or a series of data points in a chart) and format or perform operations on them. To enable this functionality, the controls will become UI active in containers that allow this, meaning they will respond to mouse and keyboard events. Any changes made to the controls in design mode will persist with the document or form when it is reloaded at runtime, resetting the controls to look exactly as they did when you saved them. Some containers make the controls UI active as soon as you click them. Others require that you double-click the control before it becomes UI active. Still other containers require you to single-click them twice to activate them. This behavior is entirely determined by the container, so refer to the container's documentation to see how it deals with COM controls at design time.
Note that this does not affect a control's runtime behavior. At runtime, all containers make the controls UI active after loading them. But some environments, such as Office documents, never get into a runtime state because you are always editing the document that's currently loaded. Internet Explorer, Visual Basic, Visual C++, Access Forms, and Office UserForms all have a runtime mode in which the controls are immediately active.
Data Access Pages and Internet Explorer 5
If you read any of the Access 2000 documentation, you will likely see statements that say you can view data access pages only in Internet Explorer version 5 and above. Although true, that statement does not apply to the Office Web Components in general. The components will function in Internet Explorer 4.01 and above, though they won't function in any earlier versions (4.0, 3.x, 2.x, and so on). This applies to any interactive content created with Excel 2000 (which uses the Office Web Components) and to custom solutions developed using the components.
Data access pages rely on a few specific features in Internet Explorer 5, which is why they only run in that environment. However, the Office Web Components themselves can run quite happily in the tested containers listed earlier.
Using the Office Web Components on a Server
As mentioned before, the Office Web Components were designed to run both as controls "sited" within a form, document, or web page, and as objects in memory with no user interface. Each of the controls exposes a property or method that returns a static representation of its current content. The Chart and PivotTable controls can create GIF images of their content, and the Spreadsheet control can return an HTML table fragment or full page that can be rendered by any browser that's compatible with HTML 3.2. All of this means you can use the components on a web server to perform server-side generation of chart images and PivotTable reports or server-side recalculation of a spreadsheet model. I'll demonstrate a few of these techniques in Part II of the book.
Besides discussing the how-to of using the components on the server, we'll examine a number of more subtle issues related to performance, scalability, and reliability later in the book.
Deployment
One of the more attractive aspects of web-based solutions is that they don't require explicit setup of an application. Anything needed is either included with the web page in the form of scripts or is automatically downloaded as applets or COM controls. The Office Web Components enable a no-install deployment and automatic upgrade mechanism by using the codebase feature of Internet Explorer. The components also include a sophisticated web installing control that makes the download experience much more attractive. Furthermore, OWC has no technological dependency on Office 2000, so it can coexist in an Office 97 environment or be used on a machine that doesn't have any other part of Office installed.
I'll cover all the aspects of deployment and how you can build your solutions to automatically deploy OWC in Chapter 12.
What About Netscape Navigator?
When I talk about the Office Web Components at conferences or other customer gatherings, invariably someone asks the question, "Do these run in Netscape Navigator?" The answer is essentially "no," but it has a few caveats.
Netscape Navigator 4.5 does not natively support COM controls, so without any plug-ins, the Office Web Components won't even be loaded by Netscape Navigator. However, a company called NCompass Labs, Inc. makes a plug-in for Netscape Navigator that can host COM controls in a web page. So if you installed this plug-in, could you use the components in Netscape Navigator? The answer is "it depends" and, again, has a few caveats.
Many solutions you might build with OWC involve communication between the components—for instance, a chart bound to a PivotTable or spreadsheet, or a spreadsheet cell bound to the property of another element on the page. These solutions depend on functionality provided in Internet Explorer that isn't present in Netscape Navigator even with the NCompass plug-in, so they simply won't work in Netscape Navigator.
Using a single component or multiple components that do not communicate with one another is possible in Netscape Navigator. However, this is one of the containers that our test team did not research, so I can't guarantee that it will work.
You should always remember, however, that static content generated by the controls on the server can be rendered in either Netscape Navigator or Internet Explorer. So if your runtime environment requires that you support both browsers, you probably will be more interested in using the components on your web server and in the solutions that show the techniques that d
|