Dim doc As New PrintDoc '定义一个报表 doc.PageSetting.Width =250 doc.PageSetting.Height=94 doc.PageSetting.TopMargin=10 doc.PageSetting.LeftMargin=10 doc.PageSetting.RightMargin=10 doc.PageSetting.BottomMargin=0 doc.AutoRotate = False Dim rt As New prt.RenderTable() '定义一个表格对象 Dim rx As New prt.RenderText '定义一个文本对象 Dim str As String Dim dtp1 As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1") Dim dtp2 As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker2") Dim cmd As new sqlcommand cmd.C For Each dr As Row In Tables("导入_table1").GetCheckedRows cmd.CommandText="s elect 订单号,微信昵称,收货人,联系电话,商品名称,规格,数量,商品金额,订单总金额,已退金额,收货地址,导入日期,状态 from {导入} where 导入日期>=#" & dtp1.value & "# and 导入日期<#" & dtp2.value.AddDays(1) & "# and 联系电话='" & dr("联系电话") &"'" Tables("导入_table2").DataSource =cmd.ExecuteReader Tables("导入_table2").AutoSizeCols rx.text = "销售单" rx.Style.FontBold = True '字体加粗 rx.Style.FontSize = cstr(Tables("打印设置").Current("标题字体大小")) rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中排列 rx.Style.Spacing.Bottom = cstr(Tables("打印设置").Current("表格离表头距离")) doc.Body.Children.Add(rx) '加入到报表中 rx = new prt.RenderText rx.text ="客户名称:" & dr("收货人") rx.y=cstr(Tables("打印设置").Current("客户名称上位置")) rx.Style.TextAlignHorz = prt.AlignHorzEnum.left '水平居中排列 rx.Style.Spacing.Bottom = 1 '和下面的对象(表格)距离3毫米 doc.Body.Children.Add(rx) '加入到报表中 '指定行数?列数?列宽?行高 rx = new prt.RenderText rx.text ="日期:" & format(Date.Today, "yyyy-MM-dd") rx.y=cstr(Tables("打印设置").Current("客户名称上位置")) rx.x=cstr(Tables("打印设置").Current("日期左位置")) rx.Style.TextAlignHorz = prt.AlignHorzEnum.left '水平居中排列 rx.Style.Spacing.Bottom = 1 '和下面的对象(表格)距离3毫米 doc.Body.Children.Add(rx) '加入到报表中 rx = new prt.RenderText rx.text ="联系电话:" & dr("联系电话") rx.y=cstr(Tables("打印设置").Current("客户名称上位置")) rx.x=cstr(Tables("打印设置").Current("电话左位置")) ''rx.Style.FontBold = True '字体加粗 rx.Style.TextAlignHorz = prt.AlignHorzEnum.left '水平居中排列 rx.Style.Spacing.Bottom = 1 '和下面的对象(表格)距离3毫米 doc.Body.Children.Add(rx) '加入到报表中 rx = new prt.RenderText rx.text ="收货地址:" & dr("收货地址") rx.y=cstr(Tables("打印设置").Current("地址上位置")) rx.Style.TextAlignHorz = prt.AlignHorzEnum.left '水平居中排列 rx.Style.Spacing.Bottom = 1 '和下面的对象(表格)距离3毫米 doc.Body.Children.Add(rx) '加入到报表中 '指定行数?列数?列宽?行高 Dim i As Integer=1 Dim CurRow As Row rt.Cols.Count = 5 '报表_table1总列数 rt.CellStyle.Spacing.All = 1 '单元格内容缩进1毫米 rt.Style.GridLines.All = New prt.Linedef '报表_table1网格线 rt.Style.TextAlignVert = prt.AlignVertEnum.Center '内容垂直居中 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center rt.Style.FontSize = 13 '大体大小为16磅 rt.Cells(0,0).Text= "序号" rt.Cells(0,1).Text= "商品名称" rt.Cells(0,2).Text = "规格" rt.Cells(0,3).Text = "数量" rt.Cells(0,4).Text = "金额" Dim sl As Double=0 Dim je As Double=0 Dim xh As Integer=1 For Each r As Row In Tables("导入_table2").Rows CurRow= r rt.Cells(i,0).Text= xh rt.Cells(i,1).Text =CurRow("商品名称") rt.Cells(i,2).Text= CurRow("规格") rt.Cells(i,3).Text= CurRow("数量") rt.Cells(i,4).Text= CurRow("商品金额") str= CurRow("商品名称") sl=sl+CurRow("数量") je=je+CurRow("商品金额") i=i+1 xh=xh+1 Next Doc.Print Next
|