Foxtable(狐表)用户栏目专家坐堂 → 专业报表


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

主题:专业报表

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


加好友 发短信
等级:狐精 帖子:3236 积分:21495 威望:0 精华:0 注册:2016/3/28 16:57:00
专业报表  发帖心情 Post By:2025/4/30 11:20:00 [只看该作者]

老师,我表结构如下:

图片点击可在新窗口打开查看此主题相关图片如下:微信截图_20250430111743.png
图片点击可在新窗口打开查看
如果一级标题有3个,生成时就按照顺序为第一章、第二章、第三章,
第一个一级标题对应有2个二级标题,生产为第一节、第二节
代码该怎么修改?
Dim doc As New PrintDoc '定义一个报表
Dim rt As prt.RenderText '定义一个文本对象
Dim s As String '定义字符变量
For Each r As Row In Tables("表A").Rows
    If r("一级标题") <> ""Then
        s = "第一章  " & r("一级标题")
        rt = New prt.RenderText
        rt.Text = s '设置文本对象的内容
        rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.Style.Font = New Font("黑体", 16, FontStyle.Bold) '设置字体
        rt.Style.Spacing.top = 5 '设置上间隔为5毫米
'        rt.Style.Spacing.Bottom = 5 '设置下间隔为5毫米
        rt.Style.LineSpacing = 200 '2.0倍行距
        doc.Body.Children.Add(rt) '将文本对象加入到报表
    End If
    If r("二级标题") <> "" Then
        s = "第一节  " & r("二级标题")
        rt = New prt.RenderText
        rt.Text = s '设置文本对象的内容
        rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.Style.Font = New Font("黑体", 14, FontStyle.Bold) '设置字体
        rt.Style.Spacing.top = 5 '设置上间隔为5毫米
        rt.Style.Spacing.Bottom = 5 '设置下间隔为5毫米
        rt.Style.LineSpacing = 150 '2.0倍行距
        doc.Body.Children.Add(rt) '将文本对象加入到报表
    End If
    If r("三级标题") <> "" Then
        s = "一、" & r("三级标题")
        rt = New prt.RenderText
        rt.Text = s '设置文本对象的内容
        rt.Style.LineSpacing = 200 '1.5倍行距
        rt.Style.TextIndent = 10 '首行缩进10毫米
        doc.Body.Children.Add(rt) '将文本对象加入到报表
    Else
        s = r("正文")
        rt = New prt.RenderText
        rt.Text = s '设置文本对象的内容
        rt.Style.TextIndent = 7 '首行缩进10毫米
        rt.Style.Font = New Font("仿宋", 12) '设置字体
        rt.Style.LineSpacing = 200 '1.5倍行距
        doc.Body.Children.Add(rt) '将文本对象加入到报表
    End If
Next
doc.Preview() '预览
示例文件:
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.table




[此贴子已经被作者于2025/4/30 11:21:44编辑过]

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


加好友 发短信
等级:超级版主 帖子:113660 积分:578843 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2025/4/30 11:34:00 [只看该作者]

Dim i1 As Integer = 1
Dim i2 As Integer = 1
For Each r As Row In Tables("表A").Rows
    If r.IsNull("一级标题") = False Then
        s = "第" & i1 & "章  " & r("一级标题")
        i1 += 1
        i2 = 1
        rt = New prt.RenderText
        rt.Text = s '设置文本对象的内容
        rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.Style.Font = New Font("黑体", 16, FontStyle.Bold) '设置字体
        rt.Style.Spacing.top = 5 '设置上间隔为5毫米
        '        rt.Style.Spacing.Bottom = 5 '设置下间隔为5毫米
        rt.Style.LineSpacing = 200 '2.0倍行距
        doc.Body.Children.Add(rt) '将文本对象加入到报表
        s = "第" & i2 & "节  " & r("二级标题")
        i2 += 1
        rt = New prt.RenderText
        rt.Text = s '设置文本对象的内容
        rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.Style.Font = New Font("黑体", 16, FontStyle.Bold) '设置字体
        rt.Style.Spacing.top = 5 '设置上间隔为5毫米
        '        rt.Style.Spacing.Bottom = 5 '设置下间隔为5毫米
        rt.Style.LineSpacing = 200 '2.0倍行距
        doc.Body.Children.Add(rt) '将文本对象加入到报表
    Else
        s = "第" & i2 & "节  " & r("二级标题")
        i2 += 1
        rt = New prt.RenderText
        rt.Text = s '设置文本对象的内容
        rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.Style.Font = New Font("黑体", 16, FontStyle.Bold) '设置字体
        rt.Style.Spacing.top = 5 '设置上间隔为5毫米
        '        rt.Style.Spacing.Bottom = 5 '设置下间隔为5毫米
        rt.Style.LineSpacing = 200 '2.0倍行距
        doc.Body.Children.Add(rt) '将文本对象加入到报表
    End If
Next

 回到顶部