以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]专业报表插入图片 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=177858) |
-- 作者:riverzhang163 -- 发布时间:2022/6/7 17:27:00 -- [求助]专业报表插入图片 根据内容生成报表,显示为如下格式,原打算是在“前幅”和“后幅”列显示与“款号”相应的产品不同部位图片,但是写的语句无法达到效果,恳请大神帮忙。 Dim doc As New PrintDoc \'定义一个报表 Dim tbl As Table = Tables("未满箱明细_table1") For i As Integer = tbl.Toprow To tbl.BottomRow Dim rw As Row = tbl.Rows(i) Dim ra As New prt.RenderArea Dim rt As New prt.RenderTable() \'定义一个表格对象 Dim rx As New prt.RenderText \'定义一个文本对象 Dim Rows As List(Of DataRow) \'定义行集合 Doc.PageSetting.LeftMargin = 10 \'设置左边距 Doc.PageSetting.RightMargin = 10 \'设置右边距 Doc.PageSetting.TopMargin = 10 \'设置上边距 Doc.PageSetting.BottomMargin = 10 \'设置下边距 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) \'加入到报表中 Dim ColNames As String() = New String(){"客人名称","款号","前幅","后幅","客人订单号","客人交期","数量","已完成数量","已出货数量","库存数量"} Dim MergeCols As Integer = 4 \'指定要合并的列数 tbl.Sort = "客人名称,款号,前幅,后幅" \'根据合并列排序 rt.Width = "Auto" rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded rt.Style.Font = tbl.Font rt.Style.TextAlignVert = prt.AlignVertEnum.Center rt.RepeatGridLinesVert = True \'换页后重复表格线 For c As Integer = 0 To ColNames.Length - 1 Dim lr As Integer \' 用于保存合并区域的起始行 rt.Cells(0,c).Text = ColNames(c) rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center rt.Cols(c).Width = tbl.Cols(ColNames(c)).PrintWidth If tbl.Cols(ColNames(c)).IsNumeric OrElse tbl.Cols(ColNames(c)).IsDate Then rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right End If For r As Integer = 0 To tbl.Rows.Count - 1 If c <= MergeCols - 1 Then \'如果是要合并的列 Dim Merge As Boolean = True If r = 0 Then Merge = False Else For n As Integer = 0 To c If tbl.Rows(r)(ColNames(n)) <> tbl.Rows(r - 1)(ColNames(n)) Merge = False Exit For End If Next End If If Merge Then rt.Cells(lr,c).SpanRows = rt.Cells(lr,c).SpanRows + 1 Else rt.Cells(r + 1, c).Text = tbl.Rows(r)(ColNames(c)) rt.Cells(r + 1, c).VertSplitBehavior = prt.CellSplitBehaviorEnum.Copy \'换页后重复单元格 lr = r + 1 End If Else rt.Cells(r + 1, c).Text = tbl.Rows(r)(ColNames(c)) End If Next Next rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) rt.CellStyle.Spacing.All = 0.5 rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never rt.Cells(1,2).Image = GetImage(rw("前幅")) rt.Cells(1,3).Image = GetImage(rw("后幅")) ra.Children.Add(rt) Doc.Body.ChildRen.Add(ra) doc.Body.Children.Add(rt) Next |
-- 作者:有点蓝 -- 发布时间:2022/6/7 17:38:00 -- 1、 Dim ColNames As String() = New String(){"客人名称","款号","前幅","后幅","客人订单号","客人交期","数量","已完成数量","已出货数量","库存数量"} 改为 Dim ColNames As String() = New String(){"客人名称","款号","客人订单号","客人交期","数量","已完成数量","已出货数量","库存数量"} 2、 rt.Cells(1,2).Image = GetImage(rw("前幅")) rt.Cells(1,3).Image = GetImage(rw("后幅")) 改为 rt.Cells(i+1,2).Image = GetImage(rw("前幅")) rt.Cells(i+1,3).Image = GetImage(rw("后幅")) |
-- 作者:riverzhang163 -- 发布时间:2022/6/7 18:20:00 -- 谢谢有点蓝。 但是显示错误:.NET Framework 版本:2.0.50727.9164 Foxtable 版本:2018.10.9.1 错误所在事件:窗口,未满箱明细,生成报表,Click 详细错误信息: 添加的项目已经有所有者了。 请帮忙,谢谢!
|
-- 作者:有点蓝 -- 发布时间:2022/6/7 20:07:00 -- 调试看哪一句代码出错:http://www.foxtable.com/webhelp/topics/1485.htm |
-- 作者:riverzhang163 -- 发布时间:2022/6/8 8:44:00 -- Dim doc As New PrintDoc \'定义一个报表 Dim tbl As Table = Tables("未满箱明细_table1") For i As Integer = tbl.Toprow To tbl.BottomRow Dim rw As Row = tbl.Rows(i) Dim ra As New prt.RenderArea Dim rt As New prt.RenderTable() \'定义一个表格对象 Dim rx As New prt.RenderText \'定义一个文本对象 Dim Rows As List(Of DataRow) \'定义行集合 Doc.PageSetting.LeftMargin = 10 \'设置左边距 Doc.PageSetting.RightMargin = 10 \'设置右边距 Doc.PageSetting.TopMargin = 10 \'设置上边距 Doc.PageSetting.BottomMargin = 10 \'设置下边距 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) \'加入到报表中 MessageBox.Show(1) Dim ColNames As String() = New String(){"客人名称","款号","客人订单号","客人交期","数量","已完成数量","已出货数量","库存数量"} Dim MergeCols As Integer = 4 \'指定要合并的列数 tbl.Sort = "客人名称,款号,前幅,后幅" \'根据合并列排序 rt.Width = "Auto" rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded rt.Style.Font = tbl.Font rt.Style.TextAlignVert = prt.AlignVertEnum.Center rt.RepeatGridLinesVert = True \'换页后重复表格线 MessageBox.Show(2) For c As Integer = 0 To ColNames.Length - 1 Dim lr As Integer \' 用于保存合并区域的起始行 rt.Cells(0,c).Text = ColNames(c) rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center rt.Cols(c).Width = tbl.Cols(ColNames(c)).PrintWidth If tbl.Cols(ColNames(c)).IsNumeric OrElse tbl.Cols(ColNames(c)).IsDate Then rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right End If MessageBox.Show(3) For r As Integer = 0 To tbl.Rows.Count - 1 If c <= MergeCols - 1 Then \'如果是要合并的列 Dim Merge As Boolean = True If r = 0 Then Merge = False Else For n As Integer = 0 To c If tbl.Rows(r)(ColNames(n)) <> tbl.Rows(r - 1)(ColNames(n)) Merge = False Exit For End If Next End If If Merge Then rt.Cells(lr,c).SpanRows = rt.Cells(lr,c).SpanRows + 1 Else rt.Cells(r + 1, c).Text = tbl.Rows(r)(ColNames(c)) rt.Cells(r + 1, c).VertSplitBehavior = prt.CellSplitBehaviorEnum.Copy \'换页后重复单元格 lr = r + 1 End If Else rt.Cells(r + 1, c).Text = tbl.Rows(r)(ColNames(c)) End If Next Next MessageBox.Show(4) rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) rt.CellStyle.Spacing.All = 0.5 rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never MessageBox.Show(5) rt.Cells(i+ 1,2).Image = GetImage(rw("前幅")) rt.Cells(i+ 1,3).Image = GetImage(rw("后幅")) doc.Body.Children.Add(rt) ra.Children.Add(rt) Doc.Body.ChildRen.Add(ra) Next MessageBox.Show(6) doc.Preview() 执行后显示 3 后就不再显示了,是不是第4段出了问题
|
-- 作者:有点蓝 -- 发布时间:2022/6/8 8:55:00 -- 去掉doc.Body.Children.Add(rt) |
-- 作者:riverzhang163 -- 发布时间:2022/6/8 9:50:00 -- 去掉以后是可以运行了,但是“前幅”和“后幅”两列不见了,第一页显示空白,也没有图片显示。 请帮忙查一下怎么回事,不好意思,对于专业报表这一块不是很熟悉。 谢谢您! |
-- 作者:有点蓝 -- 发布时间:2022/6/8 10:06:00 -- 2楼第一点不用改,保留 |
-- 作者:riverzhang163 -- 发布时间:2022/6/8 10:41:00 -- 已修改如下,但是文件预览还是同附件一样,第一页是空白的,图片没有显示。 Dim doc As New PrintDoc \'定义一个报表 Dim tbl As Table = Tables("未满箱明细_table1") For i As Integer = tbl.Toprow To tbl.BottomRow Dim rw As Row = tbl.Rows(i) Dim ra As New prt.RenderArea Dim rt As New prt.RenderTable() \'定义一个表格对象 Dim rx As New prt.RenderText \'定义一个文本对象 Dim Rows As List(Of DataRow) \'定义行集合 Doc.PageSetting.LeftMargin = 10 \'设置左边距 Doc.PageSetting.RightMargin = 10 \'设置右边距 Doc.PageSetting.TopMargin = 10 \'设置上边距 Doc.PageSetting.BottomMargin = 10 \'设置下边距 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) \'加入到报表中 Dim ColNames As String() = New String(){"客人名称","款号","前幅","后幅","客人订单号","客人交期","数量","已完成数量","已出货数量","库存数量"} Dim MergeCols As Integer = 4 \'指定要合并的列数 tbl.Sort = "客人名称,款号,前幅,后幅" \'根据合并列排序 rt.Width = "Auto" rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded rt.Style.Font = tbl.Font rt.Style.TextAlignVert = prt.AlignVertEnum.Center rt.RepeatGridLinesVert = True \'换页后重复表格线 For c As Integer = 0 To ColNames.Length - 1 Dim lr As Integer \' 用于保存合并区域的起始行 rt.Cells(0,c).Text = ColNames(c) rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center rt.Cols(c).Width = tbl.Cols(ColNames(c)).PrintWidth If tbl.Cols(ColNames(c)).IsNumeric OrElse tbl.Cols(ColNames(c)).IsDate Then rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right End If For r As Integer = 0 To tbl.Rows.Count - 1 If c <= MergeCols - 1 Then \'如果是要合并的列 Dim Merge As Boolean = True If r = 0 Then Merge = False Else For n As Integer = 0 To c If tbl.Rows(r)(ColNames(n)) <> tbl.Rows(r - 1)(ColNames(n)) Merge = False Exit For End If Next End If If Merge Then rt.Cells(lr,c).SpanRows = rt.Cells(lr,c).SpanRows + 1 Else rt.Cells(r + 1, c).Text = tbl.Rows(r)(ColNames(c)) rt.Cells(r + 1, c).VertSplitBehavior = prt.CellSplitBehaviorEnum.Copy \'换页后重复单元格 lr = r + 1 End If Else rt.Cells(r + 1, c).Text = tbl.Rows(r)(ColNames(c)) End If Next Next rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) rt.CellStyle.Spacing.All = 0.5 rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never ra.Children.Add(rt) rt.Cells(i+ 1,2).Image = GetImage(rw("前幅")) rt.Cells(i+ 1,3).Image = GetImage(rw("后幅")) Doc.Body.ChildRen.Add(ra) Next doc.Preview()
|
-- 作者:riverzhang163 -- 发布时间:2022/6/8 10:42:00 -- 是不是语句的顺序需要调整,但是我不知道如何调,请帮忙,谢谢! |