日期:2014-05-18 浏览次数:20503 次
public DataTable CellSet_To_DataTable(string mdxstr) { CellSet cs=GetCellSet(mdxstr); DataTable dt = new DataTable(); dt.TableName = "ResultTable"; DataColumn dc = new DataColumn(); DataRow dr = null; //第一列:必有为维度描述(行头) dt.Columns.Add(new DataColumn("Description")); //生成数据列对象 string name; foreach (Position p in cs.Axes[0].Positions) { dc = new DataColumn(); name = ""; foreach (Member m in p.Members) { name = name + m.Caption + " "; } dc.ColumnName = name; dt.Columns.Add(dc); } //添加行数据 int pos = 0; foreach (Position py in cs.Axes[1].Positions) { dr = dt.NewRow(); //维度描述列数据(行头) name = ""; foreach (Member m in py.Members) { //name = name + m.Caption + "\r\n"; name = name + m.Caption; } dr[0] = name; //数据列 for (int x = 1; x <= cs.Axes[0].Positions.Count; x++) { dr[x] = cs[pos++].FormattedValue; } dt.Rows.Add(dr); } return dt; } #endregion }
------解决方案--------------------
使用 OWC 组件