[英]Getting data from mondrian.olap.Result
I want to store the values of result set in a variable. 我想将结果集的值存储在变量中。 Please someone help me. 请有人帮我。 Here is my code. 这是我的代码。
mondrian.rolap.RolapConnection connection=(RolapConnection)
RGHelper.getMDXConnection();
Query query = connection.parseQuery(topNUtilisedRG);
@SuppressWarnings("deprecation")
Result result = connection.execute(query);
i tried to get the result using 我试图使用获得结果
final Cell cell = result.getCell( new int[]{0,0} );
I am using eclipse debugging and I found that all records which I need are present in "cell" variable. 我正在使用eclipse调试,发现“ cell”变量中存在我需要的所有记录。 But I don't know how to fetch data. 但是我不知道如何获取数据。
In this Image I mentioned Values which I want save in some variable: 在此图像中,我提到了要保存在某些变量中的值:
I have gone through this site, but I didn't get the right solution strong text 我已经通过这个网站了,但我没有得到正确的解决方案强大的文本
You should iterate trough all cells. 您应该遍历所有细胞。 If you want get value from current cell you can call getValue() 如果要从当前单元格获取值,可以调用getValue()
result.getCell( new int[]{0,0} ).getValue()
But to get all values you must iterate like that: 但是要获得所有值,您必须像这样迭代:
Axis[] axes = result.getAxes();
int[] pos = new int[2];
pos[1] = 0;
for (Position position : axes[1].getPositions())
{
for (int i=0; i< axes[0].getPositions().size(); i++)
{
pos[0] = i;
result.getCell(pos).getValue();
}
pos[1] += 1;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.