以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]专业报表问题?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=116832)

--  作者:老鼠
--  发布时间:2018/4/1 1:08:00
--  [求助]专业报表问题?

这是目前报表代码:

Dim Doc As New PrintDoc  \'定义一个报表对象
Dim rt As  prt.RenderText   \'定义一个文本对象
Dim rm As New  prt.RenderParagraph   \'定义一个复杂图文对象
Dim f As New Font(rm.Style.Font, FontStyle.Bold)   \'定义一个加粗的字体
rm.Content.AddText("姓名:         认证年度:       认证时段:       联系电话: ", f ,Color.Red)   \'设置字体加粗,红色
rm.Width = "100%Parent"   \'设置图片尺寸为容器(页面)尺寸
rm.Height = "100%Parent"
rm.Content.AddImage(getimage("微信图片_20180305095112.jpg"))   \'设置图片
rm.Style.ImageAlign.KeepAspectRatio = True   \'拉伸图片时,保持原有比例
rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center   \'图片居中显示
Doc.Body.Children.Add(rm)  \'将图片对象加入到<主休(Body)区>报表
rt = New prt.RenderText     \'设置文本对象的内容
rt.Text = "第[PageNo]页,共[PageCount]页"   \'设置文本内容
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Right   \'设置水平靠右对齐
rt.Style.Borders.Bottom = New prt.LineDef(0.3,Color.Green)   \'设置底边框
rt.Style.Padding.Bottom = 0.5   \'底端内容缩进0.5毫米
rt.Style.FontSize = 11  \'设置字体大小为11磅
Doc.PageFooter = rt   \'设置作为页脚使用
Doc.Preview()   \'预览

 

 

需要解决的问题:我有数据表"退休认证资料",包含[姓名],[认证年度],[认证时段],[认证资料]等数据列,其中[认证资料]列为图片型.我应该如何修改代码将该数据表的相关内容引用到上面的代码中?求解!!!


--  作者:有点甜
--  发布时间:2018/4/1 17:26:00
--  

如果要打印当前选中的行,如这样写代码

 

Dim r As Row = Tables("退休认证资料").Current

rm.Content.AddImage(getimage(projectPath & "attachments/" r("认证资料")))   \'设置图片


--  作者:老鼠
--  发布时间:2018/4/1 22:16:00
--  
以下是引用有点甜在2018/4/1 17:26:00的发言:

如果要打印当前选中的行,如这样写代码

 

Dim r As Row = Tables("退休认证资料").Current

rm.Content.AddImage(getimage(projectPath & "attachments/" r("认证资料")))   \'设置图片

首先感谢你的帮助!其次代码有点小问题,不过自己解决了.

这是自己修改过的代码:

Dim Doc As New PrintDoc  \'定义一个报表对象  doc
Dim rt As  prt.RenderText   \'定义一个文本对象  rt
Dim rm As New  prt.RenderParagraph   \'定义一个复杂图文对象  rm
Dim f As New Font(rm.Style.Font, FontStyle.Bold)   \'定义一个加粗的字体 f
Dim r As Row = Tables("退休认证资料").Current   \'定义当前行为  r
rm.Content.AddText("姓名:         认证年度:       认证时段:       联系电话: ", f ,Color.Red)   \'设置字体加粗,红色
rm.Width = "100%Parent"   \'设置图片宽度尺寸
rm.Height = "100%Parent"   \'设置图片高度尺寸
rm.Content.AddImage(getimage(ProjectPath & "attachments/" & r("认证资料")))   \'设置图片
rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center      \'图片居中显示
rm.Style.Borders.All = New prt.LineDef(1,Color.Red)   \'设置边框
rm.Style.ImageAlign.StretchHorz = True   \'允许拉伸
rm.Style.ImageAlign.StretchVert = True   \'允许拉伸\'
rm.Style.Spacing.Bottom =5  \'设置下一张图片相邻下间距
Doc.Body.Children.Add(rm)  \'将图片对象加入到<主休(Body)区>报表
rt = New prt.RenderText     \'设置文本对象的内容
rt.Text = "第[PageNo]页,共[PageCount]页"   \'设置文本内容
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Right   \'设置水平靠右对齐
rt.Style.Borders.Bottom = New prt.LineDef(0.3,Color.Green)   \'设置底边框
rt.Style.Padding.Bottom = 0.5   \'底端内容缩进0.5毫米
rt.Style.FontSize = 11  \'设置字体大小为11磅
Doc.PageFooter = rt   \'设置作为页脚使用
Doc.Preview()   \'预览

 

 

可是图片居中的代码似乎没有作用了.求解????


--  作者:有点甜
--  发布时间:2018/4/1 22:25:00
--  

如果要打印标签,请用这种方式处理,如

 

http://www.foxtable.com/webhelp/scr/1182.htm

 

http://www.foxtable.com/webhelp/scr/1186.htm

 


--  作者:老鼠
--  发布时间:2018/4/2 23:59:00
--  
感谢你的帮助!目前就一个问题没有解决了:如何才能一键打印全部符合条件的行?????
这是Excel报表的条件代码:
Dim nd As String = e.Form.Controls("ComboBox1").Text
Dim sd As String = e.Form.Controls("ComboBox2").Text
Dim str As String = ""
str & = DataTables("退休认证资料").GetComboListString("公民身份号码", "认证年度 = \'" & nd & "\' Or 认证时段 = \'" & sd & "\'").replace("|", "\',\'")
Tables("退休生存人员").filter = "公民身份号码 In (\'" & str.trim(",") & "\')"

目前专业报表代码是:
Dim Doc As New  PrintDoc
Dim rm As new  prt.RenderImage
Dim rt As prt.RenderText
Dim ry As prt.RenderText
Dim r As Row = Tables("认证资料").Current
rm.Width = "100%Parent"
rm.Height = "100%Parent"
rm.image = getimage(ProjectPath & "attachments/" & r("认证照片"))
rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center
rm.Style.Borders.All = new prt.LineDef(0.3,Color.red)
rm.Style.Spacing.Bottom = 8
Doc.Body.Children.Add(rm)

rt = new prt.RenderText
rt.text = "涟源市杨市镇中心卫生院退休职工生存认证照片资料"
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Style.Fontsize = 16
Doc.PageHeader = rt

ry = new prt.RenderText
ry.text = "第[pageno]页,共[pagecount]页"
ry.Style.TextAlignHorz = prt.AlignHorzEnum.Center
ry.Style.Fontsize = 16
Doc.PageFooter = ry
Doc.Preview()

请老师们帮助!!
[此贴子已经被作者于2018/4/3 0:04:14编辑过]

--  作者:有点甜
--  发布时间:2018/4/3 9:13:00
--  

Dim nd As String = e.Form.Controls("ComboBox1").Text
Dim sd As String = e.Form.Controls("ComboBox2").Text

Dim Doc As New  PrintDoc
Dim rm As new  prt.RenderImage
Dim rt As prt.RenderText
Dim ry As prt.RenderText
For Each r As DataRow In DataTables("退休认证资料").Select("认证年度 = \'" & nd & "\' Or 认证时段 = \'" & sd & "\'")
    rm.Width = "100%Parent"
    rm.Height = "100%Parent"
    rm.image = getimage(ProjectPath & "attachments/" & r("认证照片"))
    rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center
    rm.Style.Borders.All = new prt.LineDef(0.3,Color.red)
    rm.Style.Spacing.Bottom = 8
    Doc.Body.Children.Add(rm)
next

rt = new prt.RenderText
rt.text = "涟源市杨市镇中心卫生院退休职工生存认证照片资料"
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Style.Fontsize = 16
Doc.PageHeader = rt


ry = new prt.RenderText
ry.text = "第[pageno]页,共[pagecount]页"
ry.Style.TextAlignHorz = prt.AlignHorzEnum.Center
ry.Style.Fontsize = 16
Doc.PageFooter = ry
Doc.Preview()


--  作者:老鼠
--  发布时间:2018/4/8 7:32:00
--  
以下是引用有点甜在2018/4/3 9:13:00的发言:

Dim nd As String = e.Form.Controls("ComboBox1").Text
Dim sd As String = e.Form.Controls("ComboBox2").Text

Dim Doc As New  PrintDoc
Dim rm As new  prt.RenderImage
Dim rt As prt.RenderText
Dim ry As prt.RenderText
For Each r As DataRow In DataTables("退休认证资料").Select("认证年度 = \'" & nd & "\' Or 认证时段 = \'" & sd & "\'")
    rm.Width = "100%Parent"
    rm.Height = "100%Parent"
    rm.image = getimage(ProjectPath & "attachments/" & r("认证照片"))
    rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center
    rm.Style.Borders.All = new prt.LineDef(0.3,Color.red)
    rm.Style.Spacing.Bottom = 8
    Doc.Body.Children.Add(rm)
next

rt = new prt.RenderText
rt.text = "涟源市杨市镇中心卫生院退休职工生存认证照片资料"
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Style.Fontsize = 16
Doc.PageHeader = rt


ry = new prt.RenderText
ry.text = "第[pageno]页,共[pagecount]页"
ry.Style.TextAlignHorz = prt.AlignHorzEnum.Center
ry.Style.Fontsize = 16
Doc.PageFooter = ry
Doc.Preview()

感谢帮助,录入后提示如下:.NET Framework 版本:2.0.50727.8669
Foxtable 版本:2018.3.9.1
错误所在事件:窗口,认证表打印,Button3,Click
详细错误信息:
添加的项目已经有所有者了。


--  作者:有点甜
--  发布时间:2018/4/8 8:23:00
--  

For Each r As DataRow In DataTables("退休认证资料").Select("认证年度 = \'" & nd & "\' Or 认证时段 = \'" & sd & "\'")

    rm = new  prt.RenderImage
    rm.Width = "100%Parent"
    rm.Height = "100%Parent"
    rm.image = getimage(ProjectPath & "attachments/" & r("认证照片"))
    rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center
    rm.Style.Borders.All = new prt.LineDef(0.3,Color.red)
    rm.Style.Spacing.Bottom = 8
    Doc.Body.Children.Add(rm)
Next


--  作者:老鼠
--  发布时间:2018/4/8 17:47:00
--  

感谢:有点甜老师的帮助!

还是专业报表的问题:1、为什么我要在单位名称字符后加姓名。单条打印不报错而条件打印时会报错呢?

                           2、单条信息报表打印时,为什么不是父表关联表的关联指定行呢?

这是单条打印代码:(可执行)

Dim Doc As New  PrintDoc
Dim rm As new  prt.RenderImage
Dim rt As prt.RenderText
Dim ry As prt.RenderText
Dim r As Row = Tables("退休认证资料").Current
rm.Width = "100%Parent"
rm.Height = "100%Parent"
rm.image = getimage(ProjectPath & "attachments/" & r ("认证资料"))
rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center
rm.Style.Borders.All = new prt.LineDef(0.3,Color.red)
rm.Style.Spacing.Bottom = 8
Doc.Body.Children.Add(rm)
rt = new prt.RenderText
rt.text = "涟源市杨市镇中心卫生院退休职工生存认证照片资料__" & r("姓名")
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Style.Fontsize = 16
Doc.PageHeader = rt
ry = new prt.RenderText
ry.text = "第[pageno]页,共[pagecount]页"
ry.Style.TextAlignHorz = prt.AlignHorzEnum.Center
ry.Style.Fontsize = 16
Doc.PageFooter = ry
Doc.Preview()

 

 

这是条件打印代码:(执行报错)

Dim nd As String = e.Form.Controls("ComboBox1").Text
Dim sd As String = e.Form.Controls("ComboBox2").Text
Dim Doc As New  PrintDoc
Dim rm As new  prt.RenderImage
Dim rt As prt.RenderText
Dim ry As prt.RenderText
For Each r As DataRow In DataTables("退休认证资料").Select("认证年度 = \'" & nd & "\' or 认证时段 = \'" & sd & "\'")
    rm = new  prt.RenderImage
    rm.Width = "100%Parent"
    rm.Height = "100%Parent"
    rm.image = getimage(ProjectPath & "attachments/" & r("认证资料"))
    rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center
    rm.Style.Borders.All = new prt.LineDef(0.3,Color.red)
    rm.Style.Spacing.Bottom = 8
    Doc.Body.Children.Add(rm)
Next
rt = new prt.RenderText
rt.text = "涟源市杨市镇中心卫生院退休职工生存认证照片资料__" & r("姓名")
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Style.Fontsize = 16
Doc.PageHeader = rt

ry = new prt.RenderText
ry.text = "第[pageno]页,共[pagecount]页"
ry.Style.TextAlignHorz = prt.AlignHorzEnum.Center
ry.Style.Fontsize = 16
Doc.PageFooter = ry
Doc.Preview()


--  作者:有点蓝
--  发布时间:2018/4/8 18:11:00
--  

Dim nd As String = e.Form.Controls("ComboBox1").Text
Dim sd As String = e.Form.Controls("ComboBox2").Text
Dim Doc As New  PrintDoc
Dim rm As new  prt.RenderImage
Dim rt As prt.RenderText
Dim ry As prt.RenderText
For Each r As DataRow In DataTables("退休认证资料").Select("认证年度 = \'" & nd & "\' or 认证时段 = \'" & sd & "\'")
    rm = new  prt.RenderImage
    rm.Width = "100%Parent"
    rm.Height = "100%Parent"
    rm.image = getimage(ProjectPath & "attachments/" & r("认证资料"))
    rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center
    rm.Style.Borders.All = new prt.LineDef(0.3,Color.red)
    rm.Style.Spacing.Bottom = 8
    Doc.Body.Children.Add(rm)
Next
rt = new prt.RenderText

r = Tables("退休认证资料").Current
rt.text = "涟源市杨市镇中心卫生院退休职工生存认证照片资料__" & r("姓名")
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Style.Fontsize = 16
Doc.PageHeader = rt

ry = new prt.RenderText
ry.text = "第[pageno]页,共[pagecount]页"
ry.Style.TextAlignHorz = prt.AlignHorzEnum.Center
ry.Style.Fontsize = 16
Doc.PageFooter = ry
Doc.Preview()