以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助] (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=157287) |
-- 作者:江南小镇 -- 发布时间:2020/10/10 22:47:00 -- [求助] 老师好,我想增加代码让隐藏列不导出。 Dim dlg As New SaveFileDialog dlg.Filter= "pdfl文件|*.pdf" dlg.FileName = user.name & "_Label1.pdf" If dlg.ShowDialog = DialogResult.Ok Then Dim doc As New PrintDoc \'定义一个新报表 Dim rt As New prt.RenderTable \'定义一个新表格 \' Dim tb As Table = Tables("进销存") Dim tb As Table = Tables("进销存_Table3") rt.Width = "Auto" \'表格宽度为自动,也就是等于各列设置宽度之和 doc.PageSetting.Landscape = True \'横向打印 rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页 rt.Style.Font = new Font("楷体", tb.Font.Size) For c As Integer = 0 To tb.Cols.Count -1 \'逐列设置和填入内容 rt.Cells(0,c).Text = tb.Cols(c).Name \'列名作为标题 rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中 rt.Cols(c).Width = tb.Cols(c).PrintWidth \'列宽等于实际列宽 If tb.Cols(c).IsNumeric OrElse tb.Cols(c).IsDate Then \'如果是数值或日期列 rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右 End If For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容 rt.Cells(r + 1, c).Text = tb(r,c) Next Next rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线 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) \'将表格加入到报表 doc.SavePDF(dlg.FileName) MessageBox.show("导出成功!","导出完成提示") End If
|
-- 作者:有点蓝 -- 发布时间:2020/10/11 20:29:00 -- http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=50080 rt.Style.Font = new Font("楷体", tb.Font.Size) dim idx as integer = 0 For c As Integer = 0 To tb.Cols.Count -1 \'逐列设置和填入内容 if tb.Cols(c).visible = false then continue for rt.Cells(0,idx).Text = tb.Cols(c).Name \'列名作为标题 rt.Cells(0,idx).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中 rt.Cols(idx).Width = tb.Cols(c).PrintWidth \'列宽等于实际列宽 If tb.Cols(c).IsNumeric OrElse tb.Cols(c).IsDate Then \'如果是数值或日期列 rt.Cols(idx).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右 End If For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容 rt.Cells(r + 1, idx).Text = tb(r,c) Next idx += 1 Next |
-- 作者:江南小镇 -- 发布时间:2020/10/11 22:40:00 -- 谢谢老师 |