Foxtable(狐表)用户栏目专家坐堂 → 专业报表最后出错有2个,请指正


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

主题:专业报表最后出错有2个,请指正

帅哥哟,离线,有人找我吗?
zsxx999ja
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:214 积分:2290 威望:0 精华:0 注册:2020/10/3 6:58:00
专业报表最后出错有2个,请指正  发帖心情 Post By:2020/11/11 23:04:00 [只看该作者]

下面的代码测试能打印,只是最后报了一个错

    Dim Files  As   object = FileSys.GetFiles("D:\蒋安\蒋安个人资料\督导组财务\ddzcw2020\ddzcw\Attachments")

    For i As Integer = 0 To Files.count - 1 Step 2

        Dim doc As New PrintDoc '定义一个报表

        Doc.PageSetting.LeftMargin = 20 '设置左边距

        Doc.PageSetting.RightMargin = 20 '设置右边距

        Doc.PageSetting.TopMargin = 15

        Dim f1 As String = Files(i)

        Dim bmp As bitmap

        Dim bmp2 As bitmap

        '====定义文本对象======

        Dim rs As New prt.RenderText '定义一个文本对象

        rs.Text = "龙台片区督导组出差凭证(截图)" '设置文本对象的内容

        rs.Style.TextColor = Color.Red '字符颜色设为红色

        rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中

        rs.Style.Font = New Font("宋体", 20,FontStyle.Bold) ''字符大小及类别

        rs.Style.Spacing.Bottom = 3   '以象之间的间距

        doc.Body.Children.Add(rs)

        '====定义表格对象======

        Dim rt As New prt.RenderTable() '定义一个表格对象

        Dim rm As New prt.RenderImage() '定义一个图片对象

        Dim img As Image = GetImage(f1)

        If img.Height >img.Width  Then

            img.RotateFlip(system.drawing.RotateFlipType.Rotate270FlipNone)

        End If

        If  img.Height> 265   Then

            bmp = new bitmap(img, img.width*(265/img.height),265)

            rm.image = bmp

        Else

            rm.image = img

        End If 

        rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center '图片水平居中

        rm.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center '图片垂直居中

        rm.Style.ImageAlign.StretchHorz = True '禁止水平方向扩展图片

        rm.Style.ImageAlign.StretchVert = False '禁止垂直方向扩展图片

        rm.Width = 170

        rm.Height = 70

        doc.Body.Children.Add(rt) '将表格对象加入到报表中

        rt.Style.GridLines.All = New prt.Linedef(Color.DarkGray) '将表格的颜色设为深灰色

        rt.Rows.Count = 0 '设置行数

        rt.Cols.Count = 0 '设置列数

        rt.Width = 170 '设置表格的宽度

        rt.Height = 70'设置表格的高度

        rt.Cells(0,0).RenderObject = rm '将单元格内容设置为图片对象rm

        '====定义文本对象2======

        Dim rs2 As New prt.RenderText '定义一个文本对象

        rs2.Text = "报账人:蒋安" '设置文本对象的内容

        rs2.Style.TextColor = Color.Red '字符颜色设为红色

        rs2.Style.TextAlignHorz = prt.AlignHorzEnum.right '水平居中

        rs2.Style.Font = New Font("宋体",10 , FontStyle.Bold) '

        rs2.Style.Spacing.Top = 3

        rs2.Style.Spacing.Bottom = 5   '定义两个报表之间的距离

        doc.Body.Children.Add(rs2)

        

        '=====定义中间的分隔线======

        Dim rsx As New prt.RenderText '定义一个文本对象

        rsx.Text = "- - - - - - - - - - - - - - - - - - - - - - - -  -" '设置文本对象的内容

        rsx.Style.TextColor = Color.Green '字符颜色设为红色

        rsx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中

        rsx.Style.Font = New Font("宋体", 5, FontStyle.Bold) ''字符大小及类别

        rsx.Style.Spacing.Bottom = 10    '以象之间的间距

        doc.Body.Children.Add(rsx)

        f1 = files(i+1)

        Dim rs3 As New prt.RenderText '定义一个文本对象

        rs3.Text = "龙台片区督导组出差凭证(截图)" '设置文本对象的内容

        rs3.Style.TextColor = Color.Red '字符颜色设为红色

        rs3.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中

        rs3.Style.Font = New Font("宋体", 20, FontStyle.Bold) ''字符大小及类别

        rs3.Style.Spacing.Top = 5

        rs3.Style.Spacing.Bottom = 3   '以象之间的间距

        doc.Body.Children.Add(rs3)

        '====定义表格对象======

        Dim rt2 As New prt.RenderTable() '定义一个表格对象

        Dim rm2 As New prt.RenderImage() '定义一个图片对象

        Dim img2 As image= GetImage(f1)

        If img2.Height >img2.Width  Then

            img2.RotateFlip(system.drawing.RotateFlipType.Rotate270FlipNone)

        End If

        If  img2.Height> 265   Then

            bmp2 = new bitmap(img2, img2.width*(265/img2.height),265)

            rm2.Image = bmp2

        Else

            rm2.Image = img2

        End If

        rm2.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center '图片水平居中

        rm2.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center '图片垂直居中

        rm2.Style.ImageAlign.StretchHorz = True '禁止水平方向扩展图片

        rm2.Style.ImageAlign.StretchVert = False '禁止垂直方向扩展图片

        rm2.Width = 170

        rm2.Height = 70

        doc.Body.Children.Add(rt2) '将表格对象加入到报表中

        rt2.Style.GridLines.All = New prt.Linedef(Color.DarkGray) '将表格的颜色设为深灰色

        rt2.Rows.Count = 0 '设置行数

        rt2.Cols.Count = 0 '设置列数

        rt2.Width = 170 '设置表格的宽度

        rt2.Height = 70'设7表格的高度

        rt2.Cells(0,0).RenderObject = rm2 '将单元格内容设置为图片对象rm

        '====定义文本对象2======

        Dim rs4 As New prt.RenderText '定义一个文本对象

        rs4.Text = "报账人:蒋安" '设置文本对象的内容

        rs4.Style.TextColor = Color.Red '字符颜色设为红色

        rs4.Style.TextAlignHorz = prt.AlignHorzEnum.right '水平居中

        rs4.Style.Font = New Font("宋体",10 , FontStyle.Bold) '

        rs4.Style.Spacing.Top = 3

        doc.Body.Children.Add(rs4)

        Doc.Preview() '预览报表

           Next

1、打印到最后一页后出现下面的错

 


图片点击可在新窗口打开查看此主题相关图片如下:出错.jpg
图片点击可在新窗口打开查看

2、将此段代码复制到专业报表的管理窗口的代码中,好几次都自动丢去个别句子。为什么?我是全体复制的,为什么粘贴后会丢1-2句呢?


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


加好友 发短信
等级:童狐 帖子:214 积分:2290 威望:0 精华:0 注册:2020/10/3 6:58:00
  发帖心情 Post By:2020/11/11 23:12:00 [只看该作者]

我估计是i循环最后一个时,f1 = files(i+1)取不到值,改为

If i <= Files.count-2 Then
f1 = files(i+1)
End If

请指正?


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


加好友 发短信
等级:童狐 帖子:214 积分:2290 威望:0 精华:0 注册:2020/10/3 6:58:00
  发帖心情 Post By:2020/11/11 23:15:00 [只看该作者]

改为

If i <= Files.count-2 Then
f1 = files(i+1)
End If

同样出错,同样的错。


 回到顶部
帅哥,在线噢!
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107847 积分:548592 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/11/12 9:41:00 [只看该作者]

调试技巧:http://www.foxtable.com/webhelp/scr/1485.htm,看是哪一句代码出错

丢去个别句子这个联系客服核对一下激活码

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


加好友 发短信
等级:童狐 帖子:214 积分:2290 威望:0 精华:0 注册:2020/10/3 6:58:00
  发帖心情 Post By:2020/11/18 7:45:00 [只看该作者]

当它循环到fdp图片文件时就报错并退出


图片点击可在新窗口打开查看此主题相关图片如下:123.jpg
图片点击可在新窗口打开查看

 

  Dim img2 As image= GetImage(f1)  到此句时报错,这里fdp文件也是需要打印的,如何修改才通过和通用?


 


 回到顶部
帅哥,在线噢!
有点蓝
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107847 积分:548592 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/11/18 8:45:00 [只看该作者]

pdf文件无法在专业报表里使用,只能手工打开打印。

或者使用代码先提取出图片,再处理,如:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=154637&skin=0

 回到顶部