以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  报表公式  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=21099)

--  作者:gslxzy
--  发布时间:2012/7/1 15:59:00
--  报表公式


For i As Integer = tbl.TopRow To tbl.BottomRow
    rx = New prt.RenderText
    rx.BreakBefore = prt.BreakEnum.Page \'另起一页再打印
    rx.Style.FontSize = 14
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 5
    rx.Text = "类别: " & Tables("类别").Rows(i)("类别名称")
    doc.Body.Children.Add(rx)

    rt = New prt.RenderTable
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Style.Borders.Bottom = New prt.LineDef(0.3,Color.LightGray)
    rt.CellStyle.Spacing.All = 1
    rt.Cols.Count = 4
    rt.Cells(0,0).Text = "产品名称"
    rt.Cells(0,1).Text = "单价"
    rt.Cells(0,2).Text = "库存量"
    rt.Cells(0,3).Text = "订购量"
    rt.Cells(0,4).Text = "再订购量"
    rt.Cells(0,5).Text = "中止"
    rt.rows(0).Style.Borders.Top = New prt.LineDef(1,Color.LightGray)
    rt.rows(0).Style.Borders.Bottom = New prt.LineDef(1,Color.LightGray)

    Rows = Tables("类别").Rows(i).DataRow.GetChildRows("产品")
    For r As integer = 0 To Rows.Count - 1
        rt.Cells(r+1,0).Text = rows(r)("产品名称")
        rt.Cells(r+1,1).Text = rows(r)("单价")
        rt.Cells(r+1,2).Text = rows(r)("库存量")
        rt.Cells(r+1,3).Text = rows(r)("订购量")
        rt.Cells(r+1,4).Text = rows(r)("再订购量")
        If rows(r)("中止") = True Then
            Dim rm As New prt.RenderImage
            rm.Image = getImage("Check.Ico")
            rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center
            rm.Style.ImageAlign.StretchHorz = False
            rm.Style.ImageAlign.StretchVert = False
            rt.Cells(r+1,5).RenderObject = rm
        End If
    Next

    doc.Body.Children.Add(rt)
    rx = New prt.RenderText
    rx.Style.FontBold = True
    rx.Style.Spacing.Top = 3
    rx.Text = "产品数目: " & Rows.Count
    rx.Style.TextAlignHorz = prt.AlignHorzEnum.Right
    doc.Body.Children.Add(rx)
Next
doc.Preview

 

 

这里:    rx.Text = "产品数目: " & Rows.Count,求的是产品数目,如果要求选定类别的产品的库存量,公式该怎么写


--  作者:gslxzy
--  发布时间:2012/7/1 16:41:00
--  
或者在最后加入一行,对当前列进行合计
--  作者:狐狸爸爸
--  发布时间:2012/7/2 8:54:00
--  

rx.Text = "产品数目: " & Rows.Count

 

改为:

 

rx.Text = "产品数目: " & DataTables("产品").Compute("Sum(库存)", "关联列 = \'" & tbl.Rows(i)("关联列")  & "\'")

 

 

或者:

 

Dim sum As integer = 0

For Each sr as row in rows

     sum = sum + sr("库存")

next

rx.Text = "产品数目: "  & sum

 


--  作者:gslxzy
--  发布时间:2012/7/2 23:05:00
--  

如果有一逻辑列,只对选定的列的存求合计,上面的公式又该怎样定啊


--  作者:gslxzy
--  发布时间:2012/7/2 23:06:00
--  

打错了:是

如果有一逻辑列,只对选定的列的库存合计,上面的公式又该怎样定啊


--  作者:狐狸爸爸
--  发布时间:2012/7/3 9:04:00
--  

Dim sum As integer = 0

For Each sr as row in rows

     if r("逻辑列") = True Then

          sum = sum + sr("库存")

    End if

next

rx.Text = "产品数目: "  & sum