想了很久之后,我已经完成了......
首先要明确的是,水晶报表 10 不提供以下功能“CurrentRowIndex”、“GridValueAt”,这就是为什么“CoSpringsGuy”的上述解决方案不适用......
因为我们有两张桌子。1 个客户和第 2 个产品,我们生成交叉表,其中包含 product_sold (Qty) 的汇总字段和 2 个交叉表列“Product.name”和子列产品。类型
现在我们想在 product.packing type =“Pilot” 下对每个客户销售的产品的价值求和,然后从所有产品的总和中减去总和(产品类型“Normal”和“Pilot”)
对于这个问题,首先我们必须在水晶运行时格式化公式并操作汇总字段的“显示字符串”然后我们将编辑总计,即最后一列
第一次编辑在以下代码的帮助下汇总了“显示字符串”
Global CCust As String to keeping last customer for teli new customer name
Global Ccol As String ' tht is for keeping last column/product.packing type and teli with new col
Global Rndx as number ' this is for generating index of the row
Global totperx(22) as number ' is to hold the currnt value of cell and adding with previous value
' and i imagen that number of customers will less then 22 otherwise you can take unlimited array
Whileprintingrecords
if (CCust="") then
CCust=gridrowcolumnvalue("Table_Cust.Name")
Ccol=gridrowcolumnvalue("Viw_Prod.Packing")
Rndx=1
formula="new"
end if
if CCust<>gridrowcolumnvalue("Viw_Prod.Packing") then
formula="same"
Rndx=Rndx+1
else
formula="Newag"
end if
if Ccol<>gridrowcolumnvalue("Viw_Prod.Packing") then
Rndx=1
end if
if gridrowcolumnvalue("Viw_Prod.Packing")="Pilot" then
totperx(Rndx)=totperx(Rndx)+currentfieldvalue
end if
formula=totext(currentfieldvalue,0,"") ' despite of cstr function totext will change 45 to 45 while cstr changes 45 to 45.00
CCust=gridrowcolumnvalue("Table_Cust.Name")
Ccol=gridrowcolumnvalue("Viw_Prod.Packing")
现在我们将编辑总计列的“显示字符串”
Global my as number
Global totperx(22) as number
whileprintingrecords
if my<1 then
my=1
end if
formula=currentfieldvalue-totperx(my)
my=my+1