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


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

主题:专业报表填入数据

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


加好友 发短信
等级:婴狐 帖子:8 积分:122 威望:0 精华:0 注册:2024/7/3 10:30:00
专业报表填入数据  发帖心情 Post By:2024/10/14 8:38:00 [只看该作者]

老师您好,专业报表中只填入选中的数据,代码该怎么修改呀,麻烦老师帮忙看一看
Dim doc As New PrintDoc '定义一个新报表
Dim rt As New prt.RenderTable '定义一个新表格
Dim rs As New prt.RenderText() '定义一个文本对象
Dim rss As New prt.RenderText()
Dim rs2 As New prt.RenderText()
Dim rs3 As New prt.RenderText()
Dim rs4 As New prt.RenderText()

Dim rt1 As New prt.RenderTable() '定义一个表格对象
doc.PageSetting.PaperKind = 9 '纸张A4
Doc.PageSetting.LeftMargin = 20 '设置左边距
Doc.PageSetting.RightMargin = 20 '设置右边距
Doc.PageSetting.TopMargin = 20 '设置上边距
Doc.PageSetting.BottomMargin = 20 '设置下边距

rt.Style.Spacing.Top = 3 '表格和前面对象的垂直间隔为1毫米
rt.Style.Spacing.Bottom = 1 '表和和后续对象的垂直间隔为1毫米
rs.Text = "维修单(存根)" '设置文本对象的内容
rs.y = 21
rs.Style.Font = New Font("黑体", 18) '设置文本对象的字体
rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本内容水平居中
doc.Body.Children.Add(rs) '将文本对象加入到表格中
doc.Body.Children.Add(rt1) '将表格对象加入到报表中


Dim sum As Double = 0
Dim tb As Table = Tables("维修结账") 
Dim Colnames As String() = {"编号", "维修地点", "维修时间", "维修项目", "维修费用"}
rt.Style.Font = tb.Font
rt.y = 28
rt.Style.Font = New Font("黑体", 11)
rt.Height = 80
rt.Cols(0).Width = 20 '设置列宽
rt.Cols(1).Width = 35
rt.Cols(2).Width = 20
rt.Cols(3).Width = 55
rt.Cols(4).Width = 20
rt.Cells(6, 1).SpanCols = 2 '第7行第1个单元格向右合并5列
rt.Cells(7, 1).SpanCols = 2 '第7行第1个单元格向右合并5列
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中


For c As Integer = 0 To Colnames.length - 1 '逐列设置和填入内容
    rt.Cells(0, c).Text = colnames(c) '列名作为标题
    rt.Cells(0, c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
    rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '数据水平靠右
    Dim i As Integer = 1

??????


    
    Next
Next

rt.Cells(6, 0).Text = "主任"
rt.Cells(6, 1).Text = "                 "
rt.Cells(6, 3).Text = "签字"
rt.Cells(6, 4).Text = "                 "
rt.Cells(7, 0).Text = "维修人"
rt.Cells(7, 1).Text = "                 "
rt.Cells(7, 3).Text = "报销时间"
rt.Cells(7, 4).Text = "                 "
rt.Style.Gridlines.All = New prt.Linedef '灰色网格线
rt.CellStyle.Spacing.All = 0.5 '单元格内距设为0.5毫米
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
rt.RowGroups(0, 1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头
doc.Body.Children.Add(rt) '将表格加入到报表


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


加好友 发短信
等级:超级版主 帖子:110130 积分:560456 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2024/10/14 9:03:00 [只看该作者]


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


加好友 发短信
等级:超级版主 帖子:110130 积分:560456 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2024/10/14 9:05:00 [只看该作者]

……
Dim i As Integer = 1
    For k as Integer = tb.TopPosition To tb.BottomPosition
        .Rows(i).Locked = 
True
rt.Cells(i, c).Text = tb.Rows(k)(colnames(c))
    Next
……

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


加好友 发短信
等级:婴狐 帖子:8 积分:122 威望:0 精华:0 注册:2024/7/3 10:30:00
专业报表填入数据  发帖心情 Post By:2024/10/14 9:40:00 [只看该作者]

谢谢
[此贴子已经被作者于2024/10/14 9:41:23编辑过]

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


加好友 发短信
等级:婴狐 帖子:8 积分:122 威望:0 精华:0 注册:2024/7/3 10:30:00
专业报表填入数据  发帖心情 Post By:2024/10/14 9:43:00 [只看该作者]

For c As Integer = 0 To Colnames.length - 1 '逐列设置和填入内容
    rt.Cells(0, c).Text = colnames(c) '列名作为标题
    rt.Cells(0, c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
    rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '数据水平靠右
    Dim i As Integer = 1
   With Tables("维修结账")

    For k As Integer = tb.TopPosition To tb.BottomPosition
       .Rows(k).Locked = True
        rt.Cells(i, c).Text = tb.Rows(k)(colnames(c))
    Next
 
   End With 
Next
老师,我选中了多个数据,怎么只填入一个,是我这个哪里不对吗?

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


加好友 发短信
等级:超级版主 帖子:110130 积分:560456 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2024/10/14 9:51:00 [只看该作者]

For c As Integer = 0 To Colnames.length - 1 '逐列设置和填入内容
    rt.Cells(0, c).Text = colnames(c) '列名作为标题
    rt.Cells(0, c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
    rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '数据水平靠右
    Dim i As Integer = 1
    For k As Integer = tb.TopPosition To tb.BottomPosition
        rt.Cells(i, c).Text = tb.Rows(k)(colnames(c))
i=i+1
    Next
Next

 回到顶部