首页 > 开发 > 综合 > 正文

Programming Microsoft Office 2000 Web Components第一

2024-07-21 02:21:12
字体:
来源:转载
供稿:网友

商业源码热门下载www.html.org.cn

第一章第二节 office web components是什么?

office web components是一组的com控件,设计的目的是为众多的控件容器提供交互的电子表格建模,数据报表和数据可视化功能。owc库包含四个主要的组件:电子表格组件,图表组件,透视表组件和数据源组件。我们将在这一节中简要论述每个控件,然后在后续各章中讨论更多细节。



注释:

com也被称作activex。当微软发明了术语”activex”来描述com技术时,我正在visual basic小组,这个术语使得我们绝大部分的客户大吃一惊,因为这些客户在我们停止使用术语”ole”后刚刚习惯于使用术语com。我不是市场人员,所以本书中我只使用术语com来描述组件对象模型技术。



“office web components”名称中的单词”office”表示这些控件就是由那些开发微软excel和access的程序员中的一部分人开发的,并且这些控件被设计成在外观,使用感受和行为表现上就像是他们的微软office兄弟的精简版一样。这些控件确实不包含excel和access中的所有的功能——换句话说,您也不会为了在浏览器中查看一个报表而动态的下载完整的excel和access!然而,这些控件也确实包含了许多的常用功能,尤其是那些在与已有内容进行交互时所必需的功能。此外,这些控件还能够读写excel 2000的html格式的文件,允许用户点击一个按钮,将当前的数据加载到excel中,以便作更加强大的分析。本书中,我会详细描述这些被每个组件支持和不支持的excel和access的显著特性。也会向您展示如何利用自己的代码来添加一些这些控件所缺少的功能。





owc名称中的”web”部分经常使人误解。这些控件是标准的com控件,并能够在许多的控件容器中使用,例如微软internet explorer,微软visual basic,微软visual c++,微软visual foxpro和微软office用户窗体。然而,这些控件的一些行为使它们尤其适合于在internet explorer的特殊环境中使用。例如,web浏览器为文档提供自动的滚动条,但是人们经常会为页面中自带一组滚动条的控件而烦恼。电子表格控件和数据透视控件能够通过设置,自动调整大小来适合它们当前的内容,而不需要内部滚动条。此外,所有的控件都支持在internet explorer中可用的颜色名称,还支持数字rgb值。这就意味着您可以使用”cornsilk”或者”papayawhip”(我个人的爱好)元素来设置背景颜色,控件会象internet explorer那样将颜色转换成适当的rgb值。

owc名称中的”components”部分虽然比使用单词”controls”要准确的多(尽管在这本书中我会为了方便将owc称为”controls”),但是也令人相当迷惑。office web components的与众不同之处在于,他们能够在类似web页面,visual basic窗体等等控件容器中使用,也能象不可视对象那样在内存中被使用。大部分的com控件只能在控件容器中被用作可视控件,而大部分的不可视对象,例如那些通过微软ado接口访问的对象,只能在内存中使用而不能放在窗体或web页面中。owc库设计的目的是可以通过任何一种方式来使用。这使得您能够通过它们暴露的用户界面来使用这些控件或者使用这些控件的各种后台服务,例如电子表格的重新计算功能。这种能够以不可见对象的方式来使用的能力,也使您能够在服务器上用这些库方便地生成可以在任何web浏览器中查看的静态内容 (在这一章的后面会更多的讲到这方面的内容)。



所有控件都支持一组丰富的编程接口,这些接口能够在微软vbscript(visual basic的脚本版本),微软jscript,微软vba(visual basic for application),java,c++以及任何其它能够调用双com接口或调度com接口的语言中调用。这意味这您可以将这些组件添加到定制的解决方案中,并根据您的需要设计它们的外观和行为。我将在后续章节中讨论这些组件大部分的重要属性,方法和事件,并在这些章节中通过讲述各种解决方案来讲述这些重要内容中的绝大部分,这些解决方案可以在本书附赠的cd中找到。



参见

如果您正在寻找关于com技术的权威的指南,我建议您选读david chappell的《understanding activex and ole(microsoft press,1996)》一书。



让我们浏览一下每一个组件,并讨论我们能够使用它们来建立哪些类型的解决方案。之前已经提到过了,后面的四章将会更加深入的讨论每一个控件。



电子表格组件

电子表格组件(如图1-1所示)象一个excel电子表格的精简版,由一个电子表格用户界面和一个重算引擎组成,支持excel 2000中几乎所有的计算功能。使用这个控件,您可以改变和重新计算数值;排序,过滤和滚动数据;保护单元不被修改;甚至可以将数据重新装载到excel 2000中,以进行进一步的处理。电子表格控件能够从传入的参数中或从指向html格式的excel电子表格文件的任何url处装入数据。






图1—1 电子表格组件



当您要在企业内部互联网上创建一个有效的电子表格模型,以便其他人能够修改输入值,并立刻看到重新计算的结果时,电子表格控件是很有用的。例如抵押计算器和偿还进度表模型,产品收支平衡模型,和销售预测表。

对于任何类型的交叉表或基于表格的数据输入,尤其是当您需要使用有自动重算功能的公式时,这个控件也是很有用的。例如成本报表,事件表和预算报表。

电子表格控件能够将单元绑定到在页面上的其它对象的属性上,然后当数据源表明属性值改变时自动地更新单元以及和单元相关联的其它单元。这使得可以在电子表格中为一些特定的环境提供实时数据,例如股票组合。



为了实现即使当您在正在工作的电子表格中编辑其它的公式或者正在为其它的单元设置格式时,电子表格也能够继续监视新的数据并且重新计算,电子表格控件做了专门的设计。



图表组件

图表组件(如图1-2所示)可以说是excel图表的一个精简版,它支持excel2000中的大部分二维图表类型,例如polar图表类型。图表组件的另一个重要的特征是能够立刻显示多个图形,从而允许您创建一个小型多重设计——换句话说,根据某一属性变化的一系列图形可以立刻进行比较。一个图表可以和电子表格控件,数据透视控件或者一个ado的recordset对象进行数据绑定,或者使用原始的数据来填充。当绑定到一个数据源上时,无论何时数据源发生变化图表控件都会更新。



参见

如果需要了解小型多重设计的威力的更多信息,请看edward tufte的书《envisioning information (graphics press, 1990)》。








图1-2 图表组件



当需要用图表来表示动态的数据或监视对你的业务而言非常重要的元素时。图表控件会相当的有用。因为它提供丰富的编程模型,所以也能利用这个控件向图表中添加许多种效果,例如在坐标轴的最大范围上缩放和平移,根据鼠标的位置在应用程序中动态地改变图表的内容,或者让用户双击一个链接,转到显示所选择的数据点的更多信息的新页面。



数据透视组件

数据透视组件(如图1-3所示),是为了提供交互的数据报表和分析功能而设计的,它能提供excel数据透视表的所有功能和各种外部数据类型。它能通过ole db从表格,和关系数据库中提取数据,也能通过ole db从olap服务器的cube和cube文件中为olap提取数据。使用这个控件,您能够对数据进行各种方式的分组,切片和排序并查看,在动态数据上创建优美的报表和交互分析功能。



虽然它最适用于数据报表和数据分析解决方案,但您可以在很多任务中使用这个控件,当被绑定到一个olap cube上时,数据透视控件能够给用户提供一个灵活,高效的分析界面。it机构能够集中精力根据他们公司对数据的理解来收集和整理数据,并将数据装入cube中,而操作这个控件的用户则能够根据自己需求来对数据进行切片。






图1-3 数据透视表



数据透视报表也能直接在关系数据库上完成同样的工作,因此即使您在olap系统上没有投资,您也能够使用这个控件。然而,使用olap数据源的性能总是要快的多,原因在于这项技术的本质。olap还有其它逻辑上的好处,我们将在第七章中探讨销售分析和报表解决方式时深入的讨论它。



数据源组件

数据源组件(dsc)是需要从外部数据源获得数据的控件的骨干框架。虽然这个控件是不可见的,但是它被广泛的使用于从层次(olap中的术语)或临时olap cube中获取和处理数据(第四章中将详细介绍),以及在各种各样的控件之间建立数据关联。既然数据源组件和那些internet explorer和visual basic中的其它数据源控件一样,支持相同的标准接口,那么在这些环境中它就是可以互操作的。数据源组件在access2000的数据访问页特性中得到大量的使用,并且集成了许多access报表引擎中的功能。



当其它的组件要从外部数据库获得数据时,几乎都要用到数据源组件。然而,它也支持它自己的一个编程模型,您能使用它来建立或者操作层次的recordset对象。一般来说,您不需要过多的考虑数据源控件,因为其它组件和access2000数据访问页设计器会为您设置和调用它。



疑问:1、the "components" part of owc's name is a touch confusing这句如何翻译?

2、the pivottable component (shown in figure 1-3) provides all the functionality found in excel pivottables and external data ranges.中的external data ranges如何翻译?





附录:英文原文

what are the office web components?

the office web components are a set of component object model (com) controls designed to bring interactive spreadsheet modeling, database reporting, and data visualization to a number of control containers. the owc library contains four principal components: spreadsheet, chart, pivottable, and data source. we'll discuss each of these controls briefly in this section and in much more detail in the following chapters.

note


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

com is also known as activex. i was on the visual basic team when microsoft invented the term "activex" to describe the com technologies, throwing most of our customers for a loop since they had just gotten used to saying com after we stopped using the term "ole." since i'm not a marketing person, i'll just use the term com in this book to describe the component object model technologies. (throw…for a loop:大吃一惊)

the word "office" in the name "office web components" indicates that the controls were developed by some of the same programmers who created microsoft excel and microsoft access and that the controls were made to look, feel, and behave like small versions of their microsoft office siblings. these controls definitely don't have all the features found in excel and access—in other words, you wouldn't want to dynamically download all of excel and access to view a report in your browser! however, the controls do contain many of the commonly used features, especially those needed when interacting with content that's already been created. plus, they can read and write the html file format of excel 2000, allowing the user to click a button and load the current data into excel for more powerful analysis. in this book, i'll detail the noteworthy excel or access features that are and aren't supported by each component. i'll also show you how to add some of these missing features with your own code.

the "web" part of owc's name is often misleading. the controls are standard com controls and can be used in many control containers such as microsoft internet explorer, microsoft visual basic, microsoft visual c++, microsoft visual foxpro, or microsoft office userforms. however, the controls have a few behaviors that make them especially suited to the unique environment of internet explorer. for example, web browsers automatically support scrolling along a document, and it's often annoying for a control in the page to have its own set of scroll bars. the spreadsheet and pivottable controls can be set to automatically adjust themselves to fit their current content without requiring internal scroll bars. also, all the controls support the color names available in internet explorer in addition to supporting numeric rgb values. that means you can set the background color of an element to "cornsilk" or "papayawhip" (my personal favorite), and the control will convert the color to the appropriate rgb value just as internet explorer would.

the "components" part of owc's name is a touch confusing, although it's more accurate than using the word "controls" (though i will often refer to owc as "controls" for convenience throughout this book). the office web components are unusual in that they can be used in control containers like web pages, visual basic forms, and so on, as well as in memory as invisible objects. most com controls can be used only as visible controls in control containers, and most invisible objects, such as those accessed via the microsoft activex data objects (ado) interface, can be used only in memory and cannot be put on a form or web page. the owc library was built so that its components could be used either way, which enables you to use the controls with the user interfaces they expose or for their base services, such as spreadsheet recalculation. the ability to use the components as invisible objects also enables you to use the library on a server to easily generate static content that users can view in any web browser (more on that later in the chapter).

all the controls support a rich set of programming interfaces that you can call from microsoft vbscript (visual basic scripting edition), microsoft jscript, microsoft vba (visual basic for applications), java, c++, and any other language capable of calling a dual or dispatch com interface. that means you can weave the components into a custom solution and make them look and act the way you want. i will discuss most of the important properties, methods, and events in the subsequent chapters and will cover many more of these in the chapters describing the various solutions found on the companion cd.

see also


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

if you are looking for a definitive reference on com, i'd recommend picking up a copy of david chappell's understanding activex and ole (microsoft press, 1996).

let's take a brief look at each of the components and discuss what kinds of solutions you can build with them. as already mentioned, the next four chapters will cover each component in more depth.

the spreadsheet component

the spreadsheet component (shown in figure 1-1) is like a small version of an excel spreadsheet, complete with a spreadsheet user interface and a recalculation engine that supports nearly all the calculation functions in excel 2000. with this control, you can change or recalculate values; sort, filter, and scroll data; protect cells; and even reload the data into excel 2000 for further manipulation. the spreadsheet control can load its data from an embedded parameter or from any url that points to an excel spreadsheet saved in html file format.


figure 1-1. the spreadsheet component.

the spreadsheet control is useful anytime you want to make a spreadsheet model available on your intranet so that others can change the input and instantly view the recalculated results. examples include a mortgage calculator and payment schedule model, a product break-even model, and a sales forecasting model.

this control is also useful for any kind of cross-tabulated or grid-based data entry, especially when you need to use formulas with automatic recalculation. examples include expense reports, timesheets, and budgets.

the spreadsheet control has the ability to bind cells to properties of other objects on the page and then automatically update the cell and its dependents when the source indicates that the property value has changed. this makes it possible to feed real-time data into the spreadsheet for scenarios such as a stock portfolio.

the spreadsheet control is specifically designed to keep listening for new values and recalculating even when you are editing other formulas or formatting other cells in the spreadsheet you're working on.

the chart component

the chart component (shown in figure 1-2) is comparable to a small version of excel charting, supporting most of the two-dimensional chart types in excel 2000 as well as a polar chart type. another big feature is that the chart control can display many plots at once, allowing you to create a small-multiple design—in other words, a collection of plots that vary by one property and can be compared at a glance. a chart can be data-bound to the spreadsheet control, the pivottable control, or an ado recordset object, or it can be filled with literal data values. when bound to a data source, a chart control will update whenever the source data changes.

see also


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

for more information on the power of small-multiple designs, see edward tufte's book envisioning information (graphics press, 1990).


figure 1-2. the chart component.

the chart control is primarily useful any time you need to chart live data or monitor a specific metric critical to your business. because it supports a rich programming model, you can also add many effects to a chart with this control, such as zooming and panning on large axes, dynamically changing other content in the application based on the mouse's location, or letting users double-click to link to a new page displaying more information about the selected data point.

the pivottable component

designed to deliver interactive data reporting and analysis, the pivottable component (shown in figure 1-3) provides all the functionality found in excel pivottables and external data ranges. it can retrieve data from tabular, relational databases through ole db, as well as from olap server cubes and cube files through ole db for olap. using this control, you can view data grouped, sliced, and sorted in a variety of ways, creating polished reports and interactive analysis on live data.

you can use this control for many tasks, although it's best suited for database reporting and data analysis solutions. when bound to an olap cube, the pivottable control can provide the user with a flexible, high-performing analysis surface. it groups can concentrate on collecting and cleaning data and loading it into cubes that reflect the way their company thinks about the data, while users working with this control can create slices of the data to fit their own needs.


figure 1-3. the pivottable component.

the pivottable control can also perform the same operations directly on a relational database, so you can use it even if you don't have an investment in an olap system. however, the performance when using an olap data source is always much faster because of the nature of the technology. olap has other logical benefits that we'll discuss further when we explore the sales analysis and reporting solution in chapter 7.

the data source component

the data source component (dsc) is the backbone for controls that require data from external sources. although this control is invisible, it is widely used to retrieve data, manipulate data into hierarchies or temporary olap cubes (more on this in chapter 4), and establish data bindings between the various controls. since the dsc supports the same standard interfaces as other data source controls found in internet explorer and visual basic, it will interoperate in those environments. the dsc is used heavily in access 2000's data access pages feature and encapsulates much of the functionality found in the access reporting engine.

the dsc is involved almost any time the other components retrieve data from an external database. however, it also supports a programming model of its own, and you can use it to build or manipulate hierarchical recordset objects. in general, you don't need to think much about the dsc since the other components and the access 2000 data access page designer will set it up and implement it for you.
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表