以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 生成报表的图表问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=43074) |
-- 作者:zaldq -- 发布时间:2013/11/28 22:30:00 -- 生成报表的图表问题 将一个表的内容生成报表如员工资料卡一样的报表时如果将另一个表的照片根据姓名字段把照片拿来这个报表使用,简单说就是资料和相片不在同一个表里,只是用姓名将两表建立关联而以,现在在生成一个员工资料卡,不知道怎么把照片拿出来放在资料卡里。 |
-- 作者:有点甜 -- 发布时间:2013/11/28 22:44:00 -- 既然建立了关联,就可以用打印关联表的方式取出。 先自己看一下 |
-- 作者:zaldq -- 发布时间:2013/11/28 23:49:00 -- 我做的是专业报表的不是execl报表,好像不一样 |
-- 作者:Bin -- 发布时间:2013/11/29 8:30:00 -- 把照片放进去看简单,参考帮助. 如果是不懂获得关联行,也很简单
|
-- 作者:zaldq -- 发布时间:2013/11/29 10:21:00 -- 单个打印的时候可以了,现在就连续打印的代码不知道,有改了一个代码,每个都打印第一张照片,就是第二个NEXT要放在哪里才会使照片也随着变 |
-- 作者:Bin -- 发布时间:2013/11/29 10:23:00 -- 把你代码发出来,既然你连续打印懂得变动其他的值,图片也是同理的,怎么会不懂. |
-- 作者:zaldq -- 发布时间:2013/11/29 10:38: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("居民信息表") Dim tb2 As Table = Tables("居民信息表.相片") For i As Integer = tbl.TopRow To tbl.BottomRow For s As Integer = tb2.TopRow To tb2.BottomRow Dim rw As Row = tbl.Rows(i) Dim rh As Row = tb2.Rows(s) 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() \'预览报表
|
-- 作者:Bin -- 发布时间:2013/11/29 10:45:00 -- 你好,根据你的代码.你RH应该是每次循环都是不同的行,是没道理是相同的图片的. 如果是相同的图片,请你检查行的图片路径是否有问题,再到对应路径检查对应图片是否有问题.
|
-- 作者:狐狸爸爸 -- 发布时间:2013/11/29 11:15:00 -- 前面都是rw,到图片变成rh,会不会是这个原因:
rt.Cells(10,0).Text = rw("备注") |
-- 作者:Bin -- 发布时间:2013/11/29 11:16:00 -- RH是第二层循环,循环另外一个表,按道理也不会出问题才对呀. |