In general, the cellset results returned in adomd. Net cannot be directly used in the container control, because it does not implement the corresponding interface, so it usually needs to be converted to a able and then processed.
Code 1 Public Datatable todatatable (cellset CS)
2 {
3 Datatable dt = New Datatable ();
4 DT. tablename = " Resulttable " ;
5 Datacolumn DC = New Datacolumn ();
6 Datarow Dr = Null ;
7
8 // First column: dimension description (line header)
9 DT. Columns. Add ( New Datacolumn ( " Description " ));
10
11 // Generate a data column object
12 String Name;
13
14 Foreach (Position P In CS. Axes [ 0 ]. Positions)
15 {
16 DC = New Datacolumn ();
17 Name = "" ;
18 Foreach (Member m In P. Members)
19 {
20 Name = Name + M. Caption + " " ;
21 }
22
23 DC. columnname = Name;
24 DT. Columns. Add (DC );
25 }
26
27 // Add row data
28 Int Pos = 0 ;
29
30 Foreach (Position py In CS. Axes [ 1 ]. Positions)
31 {
32 Dr = DT. newrow ();
33
34 // Dimension description column data (row header)
35 Name = "" ;
36
37 Foreach (Member m In Py. Members)
38 {
39 Name = Name + M. Caption + " \ R \ n " ;
40 }
41 Dr [ 0 ] = Name;
42
43 // Data Column
44 For ( Int X = 1 ; X <= CS. Axes [ 0 ]. Positions. Count; x ++ )
45 {
46 Dr [x] = CS [POS ++ ]. Formattedvalue;
47 }
48 DT. Rows. Add (DR );
49 }
50 Return DT;
51 }