以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 专业报表的问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=58963) |
-- 作者:blackzhu -- 发布时间:2014/10/27 14:18:00 -- 专业报表的问题 这个代码是啥问题: 改成当前行却可以执行代码,逐行就出错! 另外一个专业报表可以读取远程图片吗? 我写了个专业报表的函数 居然连续执行了一模一样的两次
[此贴子已经被作者于2014-10-27 14:18:16编辑过]
|
-- 作者:有点甜 -- 发布时间:2014/10/27 14:26:00 -- 你的r是integer类型啊 |
-- 作者:有点甜 -- 发布时间:2014/10/27 14:27:00 -- 远程图片,必须先下载,才能image得到的。 |
-- 作者:Bin -- 发布时间:2014/10/27 14:27:00 -- 你疯了, 你不是FOREAHh 你用的是FOR 这里的R是数字 不是行 tb.rows(r) 才对
|
-- 作者:blackzhu -- 发布时间:2014/10/27 14:27:00 -- Dim e As Object = Args(0) Dim doc As New PrintDoc \'定义一个新报表 Dim rx As prt.RenderText Dim rt As New prt.RenderTable \'定义一个新表格 Dim rm As New prt.RenderImage \'定义一个图片对象 Dim ra As prt.RenderArea Dim dx As Row Dim tb As Table doc.PageSetting.PaperKind = 9 \'纸张类型改为B5 \'doc.PageSetting.Landscape = True \'横向打印 Doc.PageSetting.TopMargin = 10 Doc.PageSetting.LeftMargin = 8 \'设置左边距 Doc.PageSetting.RightMargin = 8 \'Doc.PageSetting.BottomMargin = 2 \'设置下边距 rt.Style.GridLines.All = New prt.Linedef \'设置网格线 rt.CellStyle.Spacing.All = 1 \'内容距离网格线1毫米 rt = New prt.RenderTable rt.Cols.Count = 6 rt.Cells(0,0).SpanCols = 6 \'合并第一行全部单元格,用于显示主标题 rm = New prt.RenderImage \'定义一个图片 rm.Width = "30mm" rm.Height = "20mm" rm.Style.Spacing.Right = 1 rm.Style.Spacing.left = 1 rm.Style.Spacing.Top = 1 rm.Style.Spacing.Bottom = 1 ra = rt.Cells(0,0).Area rm.Image= GetImage("xxxx.jpg") ra.Children.Add(rm) rt.Rows(0).Height = rm.Height doc.Body.Children.Add(rt) rt = New prt.RenderTable rt.Cells(1,0).text = "xxxxxxxxxx设计有限公司" rt.Cells(1,0).SpanCols = 6 \'合并第一行全部单元格,用于显示主标题 rt.Cells(1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'主标题居中 rt.Cells(1,0).Style.Font = New Font("微软雅黑", 14, FontStyle.Bold) \'设置主标题字体 rt.Rows(1).Style.Borders.All = New prt.LineDef("0mm", Color.white) \'去掉第一行的网格线 rt.Cells(2,0).text = "工艺说明" rt.Cells(2,0).SpanCols = 6 \'合并地二行全部单元格,用于显示副标题 rt.Cells(2,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'副标题内容居中 rt.Rows(2).Style.Borders.All = New prt.LineDef("0mm", Color.white) \'去掉第二行的网格线 rt.Cells(2,0).Style.Font = New Font("微软雅黑", 14, FontStyle.Bold) \'设置主标题字体 rt.Rows(2).Height = 8 \'设置第二行的高度,拉开和表格主体的距离. doc.Body.Children.Add(rt) tb = Tables(e.form.Name & "_样衣进度") dx = tb.Current If dx IsNot Nothing Then rt = New prt.RenderTable rt.Cols.Count = 6 rt.Cells(3,0).text = "品牌 : " & dx("品牌") rt.Cells(3,0).SpanCols = 3 rt.Cells(3,0).Style.TextAlignHorz = prt.AlignHorzEnum.left rt.Cells(3,3).text = "设计师 : " & dx("设计师") rt.Cells(3,3).SpanCols = 3 rt.Rows(3).Height = 6 \'设置第二行的高度,拉开和表格主体的距离. rt.Cells(3,3).Style.TextAlignHorz = prt.AlignHorzEnum.left rt.Cells(4,0).text = "季节 : " & dx("季节") rt.Cells(4,0).SpanCols = 3 rt.Rows(4).Height = 6 \'设置第二行的高度,拉开和表格主体的距离. rt.Cells(4,0).Style.TextAlignHorz = prt.AlignHorzEnum.left rt.Cells(4,3).text = "款式名称 : " & dx("款式名称") rt.Cells(4,3).SpanCols = 3 rt.Rows(4).Height = 6 \'设置第二行的高度,拉开和表格主体的距离. rt.Cells(4,3).Style.TextAlignHorz = prt.AlignHorzEnum.left rt.Cells(5,0).text = "年度 : " & dx("年度") rt.Cells(5,0).SpanCols = 3 rt.Cells(5,0).Style.TextAlignHorz = prt.AlignHorzEnum.left rt.Cells(5,3).text = "款号 : " & dx("款号") rt.Cells(5,0).SpanCols = 3 rt.Cells(5,0).Style.TextAlignHorz = prt.AlignHorzEnum.left rt.Style.Font = New font("微软雅黑",10,FontStyle.Bold) rt.Rows(5).Style.Borders.All = New prt.LineDef("0mm", Color.white) \'去掉第二行的网格线 rt.Rows(5).Style.Borders.Bottom = New prt.Linedef \'恢复第二行底端的网格线 rt.Rows(5).Height = 6 \'设置第二行的高度,拉开和表格主体的距离. doc.Body.Children.Add(rt) End If rx = New prt.RenderText rx.Style.FontSize = 10 rx.Style.Font= New Font("微软雅黑",10) rx.Style.FontBold = True rx.Style.Spacing.Top = 5 rx.Style.Spacing.Bottom = 5 rx.Text = "工艺说明:" doc.Body.Children.Add(rx) tb = Tables("工艺单") Dim r1 As Row = tb.Current If r1 IsNot Nothing Then rx = New prt.RenderText rx.Style.FontSize = 10 rx.Style.Font= New Font("微软雅黑",10) rx.Style.Spacing.Bottom = 3 rx.Text = "特别提示 : " & r1("特别提示") doc.Body.Children.Add(rx) rx = New prt.RenderText rx.Style.FontSize = 10 rx.Style.Font= New Font("微软雅黑",10) rx.Style.Spacing.Bottom = 3 rx.Text = "特别留意 : " & r1("特别留意") doc.Body.Children.Add(rx) End If Dim cnt As Integer cnt = rt.Rows.Count - 1 rt = New prt.RenderTable rt.Cols.Count = 3 rt.Style.Spacing.Top = 1 rt.Style.Spacing.Bottom = 1 tb = Tables("工艺要求") tb.AutoSizeCols Dim v11() As String = "细节项目|细节要求|工艺图片".Split("|") Dim str1 As String For Each cl As Col In Tables("工艺要求").Cols \'排除隐藏列 Select Case cl.Name Case "细节项目","细节要求","工艺图片" str1 = str1 & "," & cl.Name End Select Next Dim v21() As String = str1.Split(",") Dim cs1 As New List(of String) Dim vs1 As New List(of String) Dim s1 As String Dim ColNames() As String cs1.AddRange(v11) vs1.AddRange(v21) For Each c1 As String In cs1 If vs1.Contains(c1) Then s1 = s1 & "," & c1 End If Next s1=s1.TrimStart(",") ColNames = s1.Split(",") rt.Style.Font = tb.Font 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(0).Width = tb.Cols(ColNames(c)).PrintWidth \'列宽等于实际列宽 rt.Cells(0,2).SpanCols = 4 If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate OrElse tb.Cols(ColNames(c)).IsString Then \'如果是数值或日期列 rt.Cols(cnt).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右 End If For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容 rt.Cells(r+1,2).SpanCols = 4 rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c)) rm = New prt.RenderImage \'定义一个图片 rm.Width = "50mm" rm.Height = "25mm" rm.Style.Spacing.Right = 1 rm.Style.Spacing.left = 1 rm.Style.Spacing.Top = 1 rm.Style.Spacing.Bottom = 1 ra = rt.Cells(r+1,2).Area Dim ff As String = ProjectPath & "RemoteFiles\\工艺图片\\" & r+1("工艺图片").Split("/")(2) rm.Image= GetImage(ff) rt.Height = rm.Height ra.Children.Add(rm) Next Next rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线 rt.CellStyle.Spacing.All = 0.5 \'单元格内距设为0.5毫米 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中 rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All \'利用行组,将第一行设为表头. doc.Body.Children.Add(rt) \'将 rx = New prt.RenderText \'设置文本对象的内容 rx.Text = "第[PageNo]页,共[PageCount]页" \'设置文本内容 rx.Style.TextAlignHorz = prt.AlignHorzEnum.Right \'靠右对齐 rx.Style.Borders.Bottom = New prt.LineDef(0.3, Color.Green) \'设置底边框 rx.Style.Padding.Bottom = 0.5 \'底端内容缩进0.5毫米 rx.Style.FontSize = 10 \'字体大小为8磅 rx.Style.Font = New Font("微软雅黑",10) \'字体大小为8磅 Doc.PageFooter= rx doc.Preview() 整个代码就是这样的,第一个问题 代码出现上面的错误!,第二个就是怎么会连续执行两次代码
|
-- 作者:Bin -- 发布时间:2014/10/27 14:29:00 -- 第一个问题看2 4 楼 第一个问题你放在 For c As Integer = 0 To ColNames.Length - 1 \'逐列设置和填入内容 这个循环中,执行多少次 看你循环次数
|
-- 作者:blackzhu -- 发布时间:2014/10/27 14:42:00 -- 找到原因了 不好意思 自己的问题 能读取远程图片不?
|
-- 作者:有点甜 -- 发布时间:2014/10/27 14:46:00 -- 不能,必须先下载图片 |
-- 作者:blackzhu -- 发布时间:2014/10/27 14:50:00 -- 以下是引用Bin在2014-10-27 14:27:00的发言:
你疯了, 你不是FOREAHh 你用的是FOR 这里的R是数字 不是行 tb.rows(r) 才对 不是疯了 是晕了
|