以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  自动扩展(发货地址)列  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=42025)

--  作者:jinzhengbe
--  发布时间:2013/11/2 6:13:00
--  自动扩展(发货地址)列

 

 

我想在下面这段代码里 添加个内容

 

1 自动扩展(发货地址)列。

(哥们是个非常非常的草根,只会死读硬记,所以还望给位能给一下代码,不要给原理了,所实话,给了也看不懂,  非常非常的感谢各位的帮助)

 

  

DataTables("公斤数录入").deletefor("[公斤数] is Null")
DataTables("发货单号").deletefor("[客户名] is Null")
Dim doc As New PrintDoc
Dim rt As New prt.RenderTable()
Dim tbl As Table = Tables("公斤数录入1")
Dim tb As Table = Tables("发货单号1")
Dim ColNames As String() = New String(){"地区","客户名","发货地址"}
\'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 \'标题内容水平居中
  \'  If ColNames(c) <> "发货地址" Then \'
   \'        End If
   \' For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
 \'   \'    rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c))
   \' Next
\'Next
e.Form.Page.PaperKind = 8
doc.PageSetting.Width = 400 \'纸张宽度为100毫米
doc.PageSetting.Landscape = True \'横向打印
Doc.PageSetting.LeftMargin = 5 \'设置左边距
Doc.PageSetting.RightMargin = 5 \'设置右边距
Doc.PageSetting.TopMargin = 10 \'设置上边距
Doc.PageSetting.BottomMargin = 5 \'设置下边距
Doc.PrinterName = "HP Officejet 6500 E710n-z"

Dim rx As New prt.RenderTable
rx.Cells(0,0).Text = Date.Today
rx.Cells(0,1).Text = "T R J  list"
rx.Cells(0,2).Text = "第[PageNo]页,共[PageCount]页"
rx.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
rx.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right
rx.Style.Borders.Bottom = New prt.LineDef \'设置底边框
rx.CellStyle.Spacing.Bottom = 0.5 \'底端内容缩进0.5毫米
rx.Style.FontSize = 15 \'字体大小为8磅
Doc.PageHeader = rx \'作为页眉使用


rt.Style.Font = New Font("宋体", 15 , FontStyle.Bold) \'设置文本对象的字体

rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中
rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'垂直居中
 
rt.Style.Borders.All = New prt.Linedef(0, Color.Lavender) \'设置边框
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'垂直居中
   doc.Body.Children.Add(rt)
rt.Style.GridLines.All = New prt.Linedef


For i As Integer = Tables("发货单号1").TopPosition To Tables("发货单号1").BottomPosition
    Dim dr As DataRow  = Tables("发货单号1").Rows(i).DataRow
    Dim crs As List(of DataRow) = dr.GetChildRows("公斤数录入1")
     
\'If crs.count > 0 Then
       \' rt.Rows.Count = rt.Rows.count +1
        Dim st As Integer = rt.Rows.count - 1 \'起始行位置
        Dim nt As Integer = st \'当前行位置
        Dim cp As Integer = 4  \'当前列位置
For n As Integer = 0 To crs.count - 1
    If crs(n)("接收单位") = "ems" Then
            rt.cells(nt+1,cp).text = crs(n)("公斤数")
    End If
Next
           \'  rt.cells(st,0).text = dr("地区")
            \' rt.cells(st,1).text = dr("客户名")
             rt.cells(1,0).text = "地区"
             rt.cells(1,1).text = "客户名"
             rt.cells(1,2).text = "C/T"
             rt.cells(1,3).text = "Total"
             rt.cells(1,4).text = "重量1"
             rt.cells(1,5).text = "重量2"
             rt.cells(1,6).text = "重量3"
             rt.cells(1,7).text = "重量4"
             rt.cells(1,8).text = "重量5"
             rt.cells(1,9).text = "重量6"
             rt.cells(1,10).text = "重量7"
             rt.cells(1,11).text = "重量8"
             rt.cells(1,12).text = "重量9"
             rt.cells(1,13).text = "重量10"
             rt.cells(1,14).text = "电话1"
             rt.cells(1,15).text = "电话2"
             rt.cells(1,16).text = "发货地址"


            For n As Integer = 0 To crs.count - 1
            rt.cells(nt+1,cp).text = crs(n)("公斤数")
            rt.cells(nt+1,0).text =  dr("地区")
             rt.cells(nt+1,1).text =  dr("发货名")
           \'  rt.cells(nt+1,2).text =  crs.count
             rt.cells(nt+1,14).text =  dr("联系方式1")            
             rt.cells(nt+1,15).text =  dr("联系方式2")
             rt.cells(nt+1,16).text =  dr("发货地址")
             \' rt.Cells(nt+1, 3).Text = tbl.compute("Sum(公斤数)")
rt.Cells(st+2, 3).Text = "包"
rt.Cells(st+3, 3).Text = "鞋子"
rt.Cells(st+4, 3).Text = "饰品"

             rt.cells(nt+2,cp).text = crs(n)("包")
             rt.cells(nt+3,cp).text = crs(n)("鞋子")
             rt.cells(nt+4,cp).text = crs(n)("饰品")
             \' rt.cells(st+3,0).text =dr("发货名")
             \'rt.cells(nt+3,1).text =dr("联系方式1")
             \'rt.cells(nt+3,2).text =dr("联系方式2")
             \'rt.cells(nt+3,3).text =dr("发货地址")
             \'rt.cells(st+1,7).text = crs.count
             \'rt.cells(nt+4,0).text ="  "
        
            cp = cp + 1
            If cp = 7 Then
                cp=2
                nt = nt + 2
            End If
     Next 
\'rt.Cells(nt+4,0).SpanCols = 8  
\'rt.Cells(nt+3,1).SpanCols = 2
\'rt.Cells(nt+3,3).SpanCols = 2
\'rt.Cells(nt+3,5).SpanCols = 3
\'rt.Cells(st+1,7).Spanrows = 2

rt.cells(nt+2,cp).Style.FontSize = 10 \'字体大小为8磅

rt.cells(st,0).Style.BackColor = Color.Lavender
rt.cells(st,1).Style.BackColor = Color.Lavender
rt.cells(st,2).Style.BackColor = Color.Lavender
rt.cells(st,3).Style.BackColor = Color.Lavender
rt.cells(st,4).Style.BackColor = Color.Lavender
rt.cells(st,5).Style.BackColor = Color.Lavender
rt.cells(st,6).Style.BackColor = Color.Lavender
rt.cells(st,7).Style.BackColor = Color.Lavender
   
Next
doc.Preview() \'预览报表

[此贴子已经被作者于2013-11-2 6:16:33编辑过]

--  作者:Bin
--  发布时间:2013/11/2 9:01:00
--  
不想学习的话,请直接到项目需求板块,请人帮你做吧!
--  作者:有点甜
--  发布时间:2013/11/2 20:03:00
--  
 呃,楼主,你说的自动扩展列是什么意思?上传个例子瞧瞧。
--  作者:jinzhengbe
--  发布时间:2013/11/2 22:17:00
--  帮助中的自动扩展某一列啊


图片点击可在新窗口打开查看此主题相关图片如下:??.png
图片点击可在新窗口打开查看

 

帮助中的自动扩展某一列啊 这个在我的代码的什么地方放入才合适呢?试了好几次都不好用所以请教各位大侠啊~~


--  作者:有点甜
--  发布时间:2013/11/2 22:33:00
--  
 比如,你设置前15个列的宽度,不设置最后一个列的宽度,就自动扩展了

rt.cells(1,0).text = "地区"
rt.cells(1,1).text = "客户名"
rt.cells(1,2).text = "C/T"
rt.cells(1,3).text = "Total"
rt.cells(1,4).text = "发货地址"

rt.Cols(0).Width = 10
rt.Cols(1).Width = 10
rt.Cols(2).Width = 10
rt.Cols(3).Width = 10