1、D3).Merge ).Value合并效果格式设置 ).Font.Name黑体).Font.Size15 ).Borders(xlEdgeTop).ColorvbRed ).Borders(xlEdgeBottom).Color).Borders(xlEdgeLeft).Color).Borders(xlEdgeRight).Color不提示直接保存为本地文件 Spreadsheet1.Exportc:xxx.xls,ssExportActionNone 直接在Excel中打开 ssExportActionOpenInExcel EndSub 运行出来就是这个样子 因为整个编程中使用了VBA语
2、法,所以还是很容易理解的 如果你的机器上安装了Office2000/xp/2003 那么你的机器上已经有使用文档及开发文档了,很详尽,参照一下,应该没啥问题。我的机器装的是2003,在如下位置上有相关文档 C:ProgramFilesCommonFilesMicrosoftSharedWebComponents102052 Components112052 前面的文档都是使用帮助 OWCVBA11.CHM 是开发文档 ChartSpace对象:图形容器对象,也是顶层对象。如果要使用OWC绘制图形,至少要创建一个ChartSpace对象。所谓容器,就是说ChartSpace对象中可以包含多个图形
3、对象,最多16个。ChChart对象、ChCharts集合、ChCharts.Add()方法:ChChart是图形对象。一个柱状图、饼状图、散点图等都是一个图形对象,多个图形对象构成ChCharts集合。ChartSpace对象就包含一个ChCharts集合,这些ChChart之间互相叠加,比如簇状条形图就是多个单柱状图的叠加,圆环套圆环图就是两个单圆环图的叠加。通过ChCharts.Add()方法增加一个图形。ChSeries对象、ChSeriesCollection集合、ChSeriesCollection.Add()方法:帮助中说:一个ChSeries对象表示图中的一个系列。实际上,你可
4、以这样理解,当图形容器中包含多个图形时,一个ChSeries对象就表示其中的一个图形,可以通过ChSeriesCollection集合,可以使用数组的方式访问各个ChSeries,比如ChSeriesCollection0表示第一个图形。使用ChSeriesCollection.Add()方法在当前容器中新增一个图形。Point属性和Points集合:一个Point代表图形中的一个部分,比如柱状图的一条柱,饼状图的一个扇区等。ChChart对象提供Points集合,可以使用数组的形式访问各个Point,比如Points0表示第1个部分。Interior属性:代表一个形状的内部空间。比如,Cha
5、rtSpace对象的Interior属性代表图形容器内、图形外的空间,一个扇区Interior属性表示该扇区的内部空间。该属性在设置图形各个部分的颜色时起到重要作用。窃以为,以上对象和属性的理解、使用非常关键,顺着它们找下去,标题、图例、数据标签、字体等重要的特性都能顺利找到。OWC简介及其属性(转)2008-10-21 17:06Figure 3 Office Web Components (version 10)组件描述PivotTable使用户连接到支持 OLE DB Provider for OLAP Services 8.0 或更高版的 OLAP 数据源上 (也可连接到 Excel
6、电子数据表单 和 SQL Server 、 Access 关系数据库)。PivotTable 控件允许用户对数据进行透视、分组、筛选和排序等操作。Spreadsheet提供电子数据表单用户接口,包括重算引擎和扩展函数库。Chart图形化显示来自某个绑定数据源、PivotTable 或 Spreadsheet 控件的数据。当 Chart 组件被绑定到 PivotTable 控件且用户重新透视数据时能自动刷新。DataSource管理与后台数据库服务器的通讯。PivotTable 和 Spreadsheet 组件实际上能单独连接到数据源,不一定非得要 DataSource 组件。这是因为其 XML
7、 数据可以直接包含 OLE DB 连接串。Figure 4 PivotTable and Chart-related Objects成员PivotView表示 PivotTable 的一个特定视图. 用于对 PivotTable 视图中的行、列、标尺、格式化进行设置。PivotDataAxis包含与数据轴相关的方法和属性PivotResultColumnAxis包含与列轴相关的方法和属性PivotResultRowAxis包含与行轴相关的方法和属性PivotFieldSet多维数据集中定义的字段集PivotField多维数据集中定义的字段ChartSpace使用户连接到支持 OLE DB Pr
8、ovider for OLAP Services 8.0 或更高版的任何 OLAP 数据源上,(也可连接到 Excel 电子数据表单和 SQL Server、Access 关系数据库)。ChartSpace 允许用户图形化显示数据并且将控件绑定到一个已存在的 PivotTable 或 Spreadsheet。ChChartsChChart 对象集合ChChartChartSpace 中的单个图表,一个ChartSpace 可容纳多达64个图表。Figure 5 PivotTable Components Programmatic Interface类型ActiveView属性表示一个活动的 P
9、ivotTable 布局。该属性返回一个 PivotView 对象。ColumnAxis表示列轴中的字段。返回一个 PivotAxis 对象。ConnectionString设置连接到 Analysis Services 服务器的连接字符串,ConnectionString 属性中的 DataSource 参数决定了 OWC 组件将要使用的连接协议。DataAxis表示数据轴的规模。DataMember设置控件将要从 Analysis Services 请求的数据源名称。它与多维数据集同名。IncludedMembers定义了 PivotField 内的数据成员。该属性接受的参数为单一成员或成
10、员数组。IsIncluded设置所包含的字段并激活 PivotFieldSet。RowAxis表示行轴中的字段,返回 PivotAxis 对象。XMLData设置或返回当前用于 PivotTable 报表控件的 XML 数据。有关报表的细节 (格式和数据) 均保存在 XML 数据中。也包括了 OLAP 连接详细信息。AddCustomGroupField方法为指定的 PivotFieldSet 添加一个定制的分组字段。AddCustomGroupMember为指定的 PivotFieldSet 添加一个定制的分组成员。InsertFieldSet在行或列轴中插入一个字段集。CommandExe
11、cute事件在某个命令执行之后触发,ChartCommandIdEnum 和PivotCommandId 常量包含用于每个 OWC 组件所支持的命令清单。QueryPivotTable 激活某个查询时触发。Figure 6 Chart Component属性 为 Chart 控件定义数据源。当设置另一个控件(如:PivotTable 或 Spreadsheet)这样有效地绑定 Chart 控件到其它控件。Type象 ChartChartTypeEnum 枚举所定义的那样定义图表类型,默认类型为条形图。Figure 8 Connecting to an OLAP Data Sourcefunct
12、ion initializePivotTable(strDataMember) / This function calls the InitializePivotTableXML() Web/ methodvar iCallID = service.svcOLAP.callService(onInitializePivotTableResult,InitializePivotTableXML,strDataMember);function onInitializePivotTableResult(result) / This function handles the InitializePiv
13、otTableXML()/ Web method resulttext = result.value; / result string/ Evaluate return resultif (!result.error) / Assign the XML to the PivotList XMLData valuefrm1.PivotTable1.XMLData = text;else alert(Unhandled error - + result.errorDetail.code + + result.errorDetail.string);Figure 9 Generate XMLData
14、 for a PivotTable Control Public Function InitializePivotTableXML(ByVal _strDataMember As String) As StringDim m_XML As StringDim strOLAPConn As String = _ConfigurationSettings.AppSettings(OLAPConnectionString)TryDim objPT As PivotTableClass = New PivotTableClassobjPT.ConnectionString = strOLAPConno
15、bjPT.DataMember = strDataMemberm_XML = objPT.XMLDataobjPT = NothingCatch err As Exceptionm_XML = err & err.Source & - err.Message & _/errFinallyEnd TryReturn (m_XML)End FunctionFigure 10 LoadCustomPivotTableReport Web Method Public Function LoadCustomPivotTableReport(ByVal _strCity1 As String, ByVal
16、 strCity2 As String) As StringDim objPTView As PivotViewDim fldCity, fldName, fldProdFamily As PivotFieldDim fSetCustomers, fSetProduct As PivotFieldSetobjPT.DataMember = SalesobjPT.AllowFiltering = FalseobjPTView = objPT.ActiveViewobjPTView.TitleBar.Caption = City Comparison of Drink Define the col
17、umn elementsobjPTView.ColumnAxis.InsertFieldSet(objPTView.FieldSets(Time)objPTView.ColumnAxis.FieldSets().Fields(Year).Expanded = True Define the row elementsfSetCustomers = objPTView.FieldSets(CustomersobjPTView.RowAxis.InsertFieldSet(fSetCustomers)fSetCustomers.Fields(Country).IsIncluded = FalseSt
18、ate ProvinceName Define the members of the row elementsfldCity = fSetCustomers.Fields(CityfldCity.IncludedMembers = New Object() strCity1, strCity2 Exclude all other field row members in the fieldsetfSetProduct = objPTView.FieldSets(ProductobjPTView.RowAxis.InsertFieldSet(fSetProduct)fSetProduct.Fie
19、lds(Product DepartmentProduct CategoryProduct Subcategory).IsIncluded =FalseBrand NameProduct NamefldProdFamily = fSetProduct.Fields(Product FamilyfldProdFamily.IncludedMembers = Drink Define the measuresobjPTView.DataAxis.InsertTotal(objPTView.Totals(Store SalesobjPTView.DataAxis.Totals().NumberFor
20、mat = _Currency Return the XML data to the client side scriptFigure 11 Load the XMLData for a Custom Reportfunction LoadSavedReport() / Purpose: Call Web Service method to load the saved/ reportvar iCallID = service.svcOLAP.callService(onLoadSavedReportResult,LoadSavedReport, OLAPReport1.xml);functi
21、on onLoadSavedReportResult(result) This function handles the/ wsOLAP.onLoadSavedReportResult() Web Service resultvar text = result.value;Figure 12 JavaScript and VBScript Event Handlerscript language=javascript event=Query for=PivotTable1var sLog = document.Form1.Text1.value + ;document.Form1.Text1.
22、value = Query Event Fired. + sLog;/scriptvbscriptSub PivotTable1_CommandExecute(Command, Succeeded)Dim ptConstantsSet ptConstants = document.Form1.PivotTable1.Constants Check to see if the PivotTable list has been refreshed.If Command = ptConstants.plCommandRefresh Then Write the current data and ti
23、me to the text box.document.Form1.Text1.value = vbCrLf &PivotTable Last Refreshed on Date & at & Time & vbCrLf & document.Form1.Text1.valueEnd IfEnd SubFigure 13 Creating Custom Groups Public Function ApplyCustomGrouping(ByVal _strReportXMLData As String) As StringDim m_xml As StringDim fsTime As PivotFieldSetDim fsHalfYear As PivotFieldobjPT.XMLData = strReportXMLData Set a variable to the Time field set.fsTime = objPTView.FieldSets( Add a custom group field named Group1 to the Time field set.fsHalfYear = fsTime.AddCustomGr
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1