Foxtable(狐表)用户栏目专家坐堂 → 生成报表的图表问题


  共有3998人关注过本帖树形打印复制链接

主题:生成报表的图表问题

帅哥哟,离线,有人找我吗?
狐狸爸爸
  11楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251054 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2013/11/29 11:20:00 [只看该作者]

他这个循环有问题:

Dim tbl As Table = Tables("居民信息表")
Dim tb2 As Table = Tables("居民信息表.相片")
For i As Integer = tbl.TopRow To tbl.BottomRow
    For s As Integer = tb2.TopRow To tb2.BottomRow

 

其实第二个循环,打印的始终是居民信息表当前行对应的相片,因为第二个循环的是关联表,其实应该用GetChildRows


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  12楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251054 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2013/11/29 11:25:00 [只看该作者]

Dim Filter As String
With e.Form.Controls("xqmc2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = "小区名称= '" & .Value & "'"
    End If
End With
With e.Form.Controls("dh2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "幢号 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("fzgx2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "与户主关系 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("sfyf2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "是否育妇 = '" & .Value & "'"
    End If
End With
If Filter > "" Then
    Tables("居民信息表").Filter = Filter
End If


With Tables("居民信息表")
    .Select(0,0, .Rows.Count -1, .Cols.Count -1)
End With


Dim xqmc2 As WinForm.ComboBox = e.Form.Controls("xqmc2")
Dim dh2 As WinForm.TextBox = e.Form.Controls("dh2")
Dim fzgx2 As WinForm.ComboBox = e.Form.Controls("fzgx2")
Dim sfyf2 As WinForm.ComboBox = e.Form.Controls("sfyf2")
xqmc2.Text = ""
dh2.Text = ""
fzgx2.Text = ""
sfyf2.Text = ""


Dim doc As New PrintDoc '定义一个报表
Dim tbl As Table = Tables("居民信息表")
For i As Integer = tbl.TopRow To tbl.BottomRow
    Dim rw As Row = tbl.Rows(i)
    For Each rh As DataRow In rw.DataRow.GetChildRows("相片")
        Dim rt As New prt.RenderTable() '定义一个表格对象
        Dim rx As New prt.RenderText '定义一个文本对象
        Dim ra As New prt.RenderArea '定义一个容器
        ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never  '禁止容器因为分页而被垂直分割
        '加入标题
        rx.text = "社区居民信息卡"
        rx.Style.FontBold = True '字体加粗
        rx.Style.FontSize = 18 '大体大小为16磅
        rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中排列
        rx.Style.Spacing.Bottom = 3 '和下面的对象(表格)距离3毫米
        ra.Children.Add(rx) '加入到容器中
        '指定行数?列数?列宽?行高
        rt.Rows.Count = 11 '设置总行数
        rt.Cols.Count = 7 '设置总列数
        rt.Height = 127 '设置表格的高度为80毫米
        rt.Rows(10).Height = 30 '设置第7行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行
        rt.Cols(0).Width = 18 '设置前9列的宽度,剩余的宽度被分配给10列(显示图片的那列)
        rt.Cols(1).Width = 24
        rt.Cols(2).Width = 18
        rt.Cols(3).Width = 24
        rt.Cols(4).Width = 18
        rt.Cols(5).Width = 18
        '设置合并单元格
        rt.Cells(0,6).SpanRows = 5 '第1行第7个单元格向下合并5行(用于显示照片)
        rt.Cells(5,5).SpanCols = 2 '第5行第6个单元格向右合并2列(用于显示联系电话)
        rt.Cells(6,5).SpanCols = 2 '第6行第6个单元格向右合并2列(用于显示配偶身份证号)
        rt.Cells(7,5).SpanCols = 2 '第6行第6个单元格向右合并2列(用于显示身份证号)
        rt.Cells(8,3).SpanCols = 2 '第6行第6个单元格向右合并2列(用于显示管理单位)
        rt.Cells(9,1).SpanCols = 2 '第6行第6个单元格向右合并2列(用于显示管理单位)
        rt.Cells(9,3).SpanCols = 2 '第6行第6个单元格向右合并2列(用于显示管理单位)
        rt.Cells(9,5).SpanCols = 2 '第6行第6个单元格向右合并2列(用于显示管理单位)
        rt.Cells(10,0).SpanCols = 7 '第10行第1个单元格向右合并7列(用于显示备注)
        '设置表格样式
        rt.CellStyle.Spacing.All = 1 '单元格内容缩进1毫米
        rt.Style.Spacing.Bottom = 5 '和下一个资料卡的距离是5毫米
        rt.Style.GridLines.All = New prt.Linedef '设置网格线
        rt.Style.TextAlignVert = prt.AlignVertEnum.Center '内容垂直居中
        rt.Rows(9).Style.TextAlignVert = prt.AlignVertEnum.Top '唯独第7行是备注,内容靠上对齐
        '下面很简单,指定每一个单元格的内容
        rt.Cells(0,0).Text= "社区名称"
        rt.Cells(0,1).Text = rw("社区名称")
        rt.Cells(0,2).Text= "小区名称"
        rt.Cells(0,3).Text = rw("小区名称")
        rt.Cells(0,4).Text= "幢号"
        rt.Cells(0,5).Text = rw("幢号")
        rt.Cells(1,0).Text= "室号"
        rt.Cells(1,1).Text = rw("室号")
        rt.Cells(1,2).Text= "与户主关系"
        rt.Cells(1,3).Text = rw("与户主关系")
        rt.Cells(1,4).Text= "姓名"
        rt.Cells(1,5).Text = rw("姓名")
        rt.Cells(2,0).Text= "性别"
        rt.Cells(2,1).Text = rw("性别")
        rt.Cells(2,2).Text= "出生日期"
        rt.Cells(2,3).Text = rw("出生日期")
        rt.Cells(2,4).Text= "未孩性别"
        rt.Cells(2,5).Text = rw("未孩性别")
        rt.Cells(3,0).Text= "户口性质"
        rt.Cells(3,1).Text = rw("户口性质")
        rt.Cells(3,2).Text= "文化程度"
        rt.Cells(3,3).Text = rw("文化程度")
        rt.Cells(3,4).Text= "婚姻状况"
        rt.Cells(3,5).Text = rw("婚姻状况")
        rt.Cells(4,0).Text= "现有子女"
        rt.Cells(4,1).Text = rw("现有子女")
        rt.Cells(4,2).Text= "男孩"
        rt.Cells(4,3).Text = rw("男孩")
        rt.Cells(4,4).Text= "女孩"
        rt.Cells(4,5).Text = rw("女孩")
        rt.Cells(5,0).Text= "职业"
        rt.Cells(5,1).Text = rw("职业")
        rt.Cells(5,2).Text= "工作单位"
        rt.Cells(5,3).Text = rw("工作单位")
        rt.Cells(5,4).Text= "联系电话"
        rt.Cells(5,5).Text = rw("联系电话")
        rt.Cells(6,0).Text= "配偶姓名"
        rt.Cells(6,1).Text = rw("配偶姓名")
        rt.Cells(6,2).Text= "配偶出生日期"
        rt.Cells(6,3).Text = rw("配偶出生日期")
        rt.Cells(6,4).Text= "配偶身份证号"
        rt.Cells(6,5).Text = rw("配偶身份证号")
        rt.Cells(7,0).Text= "配偶户口性质"
        rt.Cells(7,1).Text = rw("配偶户口性质")
        rt.Cells(7,2).Text= "未孩出生日期"
        rt.Cells(7,3).Text = rw("未孩出生日期")
        rt.Cells(7,4).Text= "身份证号"
        rt.Cells(7,5).Text = rw("身份证号")
        rt.Cells(8,0).Text= "管理区域"
        rt.Cells(8,1).Text = rw("管理区域")
        rt.Cells(8,2).Text= "管理单位"
        rt.Cells(8,3).Text = rw("管理单位")
        rt.Cells(8,5).Text= "是否育妇"
        rt.Cells(8,6).Text = rw("是否育妇")
        rt.Cells(9,0).Text= "全员村居"
        rt.Cells(9,1).Text = rw("全员村居")
        rt.Cells(9,3).Text= "全员家庭编号"
        rt.Cells(9,5).Text = rw("全员家庭编号")
        rt.Cells(10,0).Text = rw("备注")
        rt.Cells(0,6).Image = GetImage(rh("相片"))
        ra.Children.Add(rt) '加入到容器中
        Doc.Body.ChildRen.Add(ra) '将容器加入到报表中
    Next
Next
Doc.Preview() '预览报表

[此贴子已经被作者于2013-11-29 11:27:44编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
zaldq
  13楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:26 积分:361 威望:0 精华:0 注册:2013/10/12 8:26:00
  发帖心情 Post By:2013/11/29 15:02:00 [只看该作者]

狐狸爸爸改的代码是可以把有照片的连续打印出来,但那个没有照片的变成打不出来了,比如我居民信息表是100人,而在联系表里有照片的才5个人,用这个代码后只打出有照片的这5个人,变成另外那95人没能连续打印出来.

 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  14楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251054 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2013/11/29 15:08:00 [只看该作者]

似乎不太可能,父表是打印选定行,以及对应的全部关联行。

 

具体的问题,最好做个简单的例子说话,方便别人测试分析。


 回到顶部
帅哥哟,离线,有人找我吗?
zaldq
  15楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:26 积分:361 威望:0 精华:0 注册:2013/10/12 8:26:00
  发帖心情 Post By:2013/11/29 15:43:00 [只看该作者]

应该是那个地方有错,我子表只有5条记录,会不会变成是用子表来关联父表的.

 回到顶部
帅哥哟,离线,有人找我吗?
zaldq
  16楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:26 积分:361 威望:0 精华:0 注册:2013/10/12 8:26:00
  发帖心情 Post By:2013/11/29 15:50:00 [只看该作者]

会不会还要再加一个判断IF语句,判断如果子表已循环完成,判断父表是否循环结束,如果未结束则继续循环父表

 回到顶部
帅哥哟,离线,有人找我吗?
Bin
  17楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2013/11/29 15:52:00 [只看该作者]

没照片当然就打不出来,这有什么问题
?

 回到顶部
帅哥哟,离线,有人找我吗?
zaldq
  18楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:26 积分:361 威望:0 精华:0 注册:2013/10/12 8:26:00
  发帖心情 Post By:2013/11/29 15:58:00 [只看该作者]

我现在就是想把选定的没照片的也一起打印出来

 回到顶部
帅哥哟,离线,有人找我吗?
Bin
  19楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2013/11/29 15:59:00 [只看该作者]

上例子吧

 回到顶部
帅哥哟,离线,有人找我吗?
zaldq
  20楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:26 积分:361 威望:0 精华:0 注册:2013/10/12 8:26:00
  发帖心情 Post By:2013/11/30 10:37:00 [只看该作者]

谢谢狐狸爸爸,我把你给的语句那条循环的位置改了一下现在可以了,那个循环语句应该放在最下面读照片时做循环:如下:

Dim Filter As String
With e.Form.Controls("xqmc2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = "小区名称= '" & .Value & "'"
    End If
End With
With e.Form.Controls("dh2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "幢号 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("fzgx2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "与户主关系 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("sfyf2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "是否育妇 = '" & .Value & "'"
    End If
End With
If Filter > "" Then
    Tables("居民信息表").Filter = Filter
End If

With Tables("居民信息表")
     .Select(0,0, .Rows.Count -1, .Cols.Count -1)
End With

Dim xqmc2 As WinForm.ComboBox = e.Form.Controls("xqmc2")
Dim dh2 As WinForm.TextBox = e.Form.Controls("dh2")
Dim fzgx2 As WinForm.ComboBox = e.Form.Controls("fzgx2")
Dim sfyf2 As WinForm.ComboBox = e.Form.Controls("sfyf2")
xqmc2.Text = ""
dh2.Text = ""
fzgx2.Text = ""
sfyf2.Text = ""

Dim doc As New PrintDoc '定义一个报表
Dim tbl As Table = Tables("居民信息表")
For i As Integer = tbl.TopRow To tbl.BottomRow
     Dim rw As Row = tbl.Rows(i)
      Dim rt As New prt.RenderTable() '定义一个表格对象
    Dim rx As New prt.RenderText '定义一个文本对象
    Dim ra As New prt.RenderArea '定义一个容器
    ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never  '禁止容器因为分页而被垂直分割
    '加入标题
    rx.text = "社区居民信息卡"
    rx.Style.FontBold = True '字体加粗
    rx.Style.FontSize = 18 '大体大小为16磅
    rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中排列
    rx.Style.Spacing.Bottom = 3 '和下面的对象(表格)距离3毫米
    ra.Children.Add(rx) '加入到容器中
    '指定行数?列数?列宽?行高
rt.Rows.Count = 11 '设置总行数
rt.Cols.Count = 7 '设置总列数
rt.Height = 127 '设置表格的高度为80毫米
rt.Rows(10).Height = 30 '设置第7行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行
rt.Cols(0).Width = 18 '设置前9列的宽度,剩余的宽度被分配给10列(显示图片的那列)
rt.Cols(1).Width = 24
rt.Cols(2).Width = 18
rt.Cols(3).Width = 24
rt.Cols(4).Width = 18
rt.Cols(5).Width = 18
'设置合并单元格
rt.Cells(0,6).SpanRows = 5 '第1行第7个单元格向下合并5行(用于显示照片)
rt.Cells(5,5).SpanCols = 2 '第5行第6个单元格向右合并2列(用于显示联系电话)
rt.Cells(6,5).SpanCols = 2 '第6行第6个单元格向右合并2列(用于显示配偶身份证号)
rt.Cells(7,5).SpanCols = 2 '第6行第6个单元格向右合并2列(用于显示身份证号)
rt.Cells(8,3).SpanCols = 2 '第6行第6个单元格向右合并2列(用于显示管理单位)
rt.Cells(9,1).SpanCols = 2 '第6行第6个单元格向右合并2列(用于显示管理单位)
rt.Cells(9,3).SpanCols = 2 '第6行第6个单元格向右合并2列(用于显示管理单位)
rt.Cells(9,5).SpanCols = 2 '第6行第6个单元格向右合并2列(用于显示管理单位)
rt.Cells(10,0).SpanCols = 7 '第10行第1个单元格向右合并7列(用于显示备注)
'设置表格样式
  rt.CellStyle.Spacing.All = 1 '单元格内容缩进1毫米
    rt.Style.Spacing.Bottom = 5 '和下一个资料卡的距离是5毫米
    rt.Style.GridLines.All = New prt.Linedef '设置网格线
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center '内容垂直居中
    rt.Rows(9).Style.TextAlignVert = prt.AlignVertEnum.Top '唯独第7行是备注,内容靠上对齐
'下面很简单,指定每一个单元格的内容
rt.Cells(0,0).Text= "社区名称"
rt.Cells(0,1).Text = rw("社区名称")
rt.Cells(0,2).Text= "小区名称"
rt.Cells(0,3).Text = rw("小区名称")
rt.Cells(0,4).Text= "幢号"
rt.Cells(0,5).Text = rw("幢号")
rt.Cells(1,0).Text= "室号"
rt.Cells(1,1).Text = rw("室号")
rt.Cells(1,2).Text= "与户主关系"
rt.Cells(1,3).Text = rw("与户主关系")
rt.Cells(1,4).Text= "姓名"
rt.Cells(1,5).Text = rw("姓名")
rt.Cells(2,0).Text= "性别"
rt.Cells(2,1).Text = rw("性别")
rt.Cells(2,2).Text= "出生日期"
rt.Cells(2,3).Text = rw("出生日期")
rt.Cells(2,4).Text= "未孩性别"
rt.Cells(2,5).Text = rw("未孩性别")
rt.Cells(3,0).Text= "户口性质"
rt.Cells(3,1).Text = rw("户口性质")
rt.Cells(3,2).Text= "文化程度"
rt.Cells(3,3).Text = rw("文化程度")
rt.Cells(3,4).Text= "婚姻状况"
rt.Cells(3,5).Text = rw("婚姻状况")
rt.Cells(4,0).Text= "现有子女"
rt.Cells(4,1).Text = rw("现有子女")
rt.Cells(4,2).Text= "男孩"
rt.Cells(4,3).Text = rw("男孩")
rt.Cells(4,4).Text= "女孩"
rt.Cells(4,5).Text = rw("女孩")
rt.Cells(5,0).Text= "职业"
rt.Cells(5,1).Text = rw("职业")
rt.Cells(5,2).Text= "工作单位"
rt.Cells(5,3).Text = rw("工作单位")
rt.Cells(5,4).Text= "联系电话"
rt.Cells(5,5).Text = rw("联系电话")
rt.Cells(6,0).Text= "配偶姓名"
rt.Cells(6,1).Text = rw("配偶姓名")
rt.Cells(6,2).Text= "配偶出生日期"
rt.Cells(6,3).Text = rw("配偶出生日期")
rt.Cells(6,4).Text= "配偶身份证号"
rt.Cells(6,5).Text = rw("配偶身份证号")
rt.Cells(7,0).Text= "配偶户口性质"
rt.Cells(7,1).Text = rw("配偶户口性质")
rt.Cells(7,2).Text= "未孩出生日期"
rt.Cells(7,3).Text = rw("未孩出生日期")
rt.Cells(7,4).Text= "身份证号"
rt.Cells(7,5).Text = rw("身份证号")
rt.Cells(8,0).Text= "管理区域"
rt.Cells(8,1).Text = rw("管理区域")
rt.Cells(8,2).Text= "管理单位"
rt.Cells(8,3).Text = rw("管理单位")
rt.Cells(8,5).Text= "是否育妇"
rt.Cells(8,6).Text = rw("是否育妇")
rt.Cells(9,0).Text= "全员村居"
rt.Cells(9,1).Text = rw("全员村居")
rt.Cells(9,3).Text= "全员家庭编号"
rt.Cells(9,5).Text = rw("全员家庭编号")
rt.Cells(10,0).Text = rw("备注")
 For Each rh As DataRow In rw.DataRow.GetChildRows("相片")
  rt.Cells(0,6).Image = GetImage(rh("相片"))
 Next
 ra.Children.Add(rt) '加入到容器中
 Doc.Body.ChildRen.Add(ra) '将容器加入到报表中
  Next
Doc.Preview() '预览报表

 回到顶部
总数 20 上一页 1 2