Cell 范例

如下代码演示访问指定 Cell 的三个方法。该代码假定在 OLAP 服务器上存在名为 Bobs Video Store 的数据源。

Dim cat      As New ADOMD.Catalog

Dim cst      As New ADOMD.Cellset

Dim cll      As ADOMD.Cell

cat.ActiveConnection = "Data Source=Servername;" + _

   "Initial Catalog=Bobs Video Store;Provider=msolap;"

cst.Source = "SELECT [Product Category].MEMBERS ON ROWS," + _

                     "[Store State].MEMBERS ON COLUMNS" + _

               "FROM  [Bobs Video Store]" + _

               "WHERE ([Quantity])"

Set cst.ActiveConnection = cat.ActiveConnection

cst.Open

' 使用序号位置检索单元。

Set cll = cst(10)

' 使用轴数值位置检索单元。

Set cll = cst(2,2)

' 使用成员名检索单元。

' MSOLAP 提供者不支持该方法,但是对于支持由成员名

' 访问单元的提供者,该方法可以包括在内。

' Set cll = cst("Childrens", "New York State")