Foxtable(狐表)用户栏目专家坐堂 → 如何将报表存为PDF并打印


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

主题:如何将报表存为PDF并打印

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


加好友 发短信
等级:幼狐 帖子:174 积分:2349 威望:0 精华:0 注册:2015/8/12 15:36:00
如何将报表存为PDF并打印  发帖心情 Post By:2015/8/28 10:01:00 [只看该作者]

Dim doc As New PrintDoc '定义一个报表
Dim
rt As New prt.RenderTable() '定义一个表格对象
Dim
rx As New prt.RenderText '定义一个文本对象
Dim
CurRow As Row = Tables("员工").Current
'加入标题

rx.text =
"员工资料卡"
rx.Style.FontBold =
True '字体加粗
rx.Style.FontSize =
16 '大体大小为16磅
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center
'水平居中排列
rx.Style.Spacing.Bottom =
3 '和下面的对象(表格)距离3毫米
doc.Body.Children.Add(rx)
'加入到报表中
'指定行数、列数、列宽、行高

rt.Rows.Count =
7 '设置总行数
rt.Cols.Count =
5 '设置总列数
rt.Height =
80 '设置表格的高度为80毫米
rt.Rows(
6).Height = 40 '设置第7行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行
rt.Cols(
0).Width = 24 '设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列)
rt.Cols(
1).Width = 35
rt.Cols(
2).Width = 24
rt.Cols(
3).Width = 40
'设置合并单元格

rt.Cells(
0,4).SpanRows = 6 '第1行第5个单元格向下合并6行(用于显示照片)
rt.Cells(
4,1).SpanCols = 3 '第5行第2个单元格向右合并3列(用于显示地址)
rt.Cells(
6,0).SpanCols = 5 '第7行第1个单元格向右合并5列(用于显示备注)
'设置表格样式

rt.CellStyle.Spacing.All =
1 '单元格内容缩进1毫米
rt.Style.GridLines.All = New prt.Linedef
'设置网格线
rt.Style.TextAlignVert = prt.AlignVertEnum.Center
'内容垂直居中
rt.Rows(
6).Style.TextAlignVert = prt.AlignVertEnum.Top '唯独第7行是备注,内容靠上对齐
'下面很简单,指定每一个单元格的内容

rt.Cells(
0,0).Text= "姓名"
rt.Cells(
0,1).Text = CurRow("姓名")
rt.Cells(
0,2).Text= "出生日期"
rt.Cells(
0,3).Text = CurRow("出生日期")
rt.Cells(
1,0).Text= "部门"
rt.Cells(
1,1).Text = CurRow("部门")
rt.Cells(
1,2).Text= "雇佣日期"
rt.Cells(
1,3).Text = CurRow("雇佣日期")
rt.Cells(
2,0).Text= "性别"
rt.Cells(
2,1).Text = CurRow("性别")
rt.Cells(
2,2).Text= "职务"
rt.Cells(
2,3).Text = CurRow("职务")
rt.Cells(
3,0).Text= "城市"
rt.Cells(
3,1).Text = CurRow("城市")
rt.Cells(
3,2).Text= "邮政编码"
rt.Cells(
3,3).Text = CurRow("邮政编码")
rt.Cells(
4,0).Text= "地址"
rt.Cells(
4,1).Text = CurRow("地址")
rt.Cells(
5,0).Text= "家庭电话"
rt.Cells(
5,1).Text = CurRow("家庭电话")
rt.Cells(
5,2).Text= "办公电话"
rt.Cells(
5,3).Text = CurRow("办公电话")
rt.Cells(
6,0).Text = CurRow("备注")
rt.Cells(
0,4).Image = GetImage(CurRow("照片"))
doc.Body.Children.Add(rt)
'将表格对象加入到报表中
Doc.Preview()
'预览报表


在以上代码基础上,如何将其存为PDF并执行打印


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/8/28 10:04:00 [只看该作者]


 回到顶部