如何通过 crystal 报告中结果集中的索引获取字段值?
How can I get a field value by it's index within a result set in crystal reports?
我有一个将数据传递到 crystal 报告的存储过程。结果集看起来像这样;
Product | Price
----------------
Apple | 0.20
Pear | 0.35
Orange | 0.10
Tomato | 0.23
我正在以我需要的方式显示我需要的大部分数据,但无法访问整行数据,只能访问个别字段。
我可以使用 NthLargest 函数获取特定价格;
NthLargest (2,{up_Fruit;1.Price})
这个returns的值为0.23。我也想获得相关产品(番茄)
如何做到这一点?我找不到任何方法将一个字段中的值与另一个字段连接起来,例如通过获取整行。
最终我想在我的报告中展示这样的东西;
Second most expensive product is Tomato, it costs [=13=].23.
我可以管理所有的字符串格式,但无法获取价格为 0.23 的产品。
我正在使用 Crystal 语法。
用以下代码替换您的公式:
Local Stringvar array x;
Local Numbervar i;
Local Stringvar display;
x:=x+({up_Fruit;1.Product} &"-"&ToText({up_Fruit;1.Price}));
join(x);
for i:=1 to UBound(x) do
(
if ToText(NthLargest (2,{up_Fruit;1.Price})) in x[i]
then
display:=x[i]
else
display:=""
);
"Second most expensive product is "& Split(display,"-")[1] & " , it costs "& Split(display,"-")[2]
我有一个将数据传递到 crystal 报告的存储过程。结果集看起来像这样;
Product | Price
----------------
Apple | 0.20
Pear | 0.35
Orange | 0.10
Tomato | 0.23
我正在以我需要的方式显示我需要的大部分数据,但无法访问整行数据,只能访问个别字段。
我可以使用 NthLargest 函数获取特定价格;
NthLargest (2,{up_Fruit;1.Price})
这个returns的值为0.23。我也想获得相关产品(番茄)
如何做到这一点?我找不到任何方法将一个字段中的值与另一个字段连接起来,例如通过获取整行。
最终我想在我的报告中展示这样的东西;
Second most expensive product is Tomato, it costs [=13=].23.
我可以管理所有的字符串格式,但无法获取价格为 0.23 的产品。
我正在使用 Crystal 语法。
用以下代码替换您的公式:
Local Stringvar array x;
Local Numbervar i;
Local Stringvar display;
x:=x+({up_Fruit;1.Product} &"-"&ToText({up_Fruit;1.Price}));
join(x);
for i:=1 to UBound(x) do
(
if ToText(NthLargest (2,{up_Fruit;1.Price})) in x[i]
then
display:=x[i]
else
display:=""
);
"Second most expensive product is "& Split(display,"-")[1] & " , it costs "& Split(display,"-")[2]