以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]綁定表  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=137792)

--  作者:JoyGum
--  发布时间:2019/7/15 22:36:00
--  [求助]綁定表
請教老師們!在綁定表的情況下如何做到在金額欄位可以按位打印?
--  作者:有点蓝
--  发布时间:2019/7/15 22:45:00
--  
什么方式打印?execl模板?窗口打印?专业报表?

截图说明一下

--  作者:JoyGum
--  发布时间:2019/7/15 22:59:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:wechat 圖片_20190715225734.jpg
图片点击可在新窗口打开查看


--  作者:有点蓝
--  发布时间:2019/7/15 23:05:00
--  
什么方式打印?execl模板?窗口打印?专业报表?

什么地方需要按位打印?最终是什么效果?

--  作者:JoyGum
--  发布时间:2019/7/15 23:06:00
--  
專業報表
--  作者:JoyGum
--  发布时间:2019/7/15 23:10:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:wechat 圖片_20190715230716.jpg
图片点击可在新窗口打开查看


--  作者:JoyGum
--  发布时间:2019/7/15 23:20:00
--  
If Tables("Voucher.VoucherDetails").Current Is Nothing Then
    Return
End If
Dim doc As New PrintDoc  \'定義一個報表
\'設置Header

Dim rtHeader = New prt.RenderText \'設置文本對象的內容
rtHeader.Text = "第[PageNo]頁, 共[PageCount]頁" \'設置文本內容
rtHeader.Style.TextAlignHorz = prt.AlignHorzEnum.Right \'靠右對齊
rtHeader.Style.Borders.Bottom = New prt.LineDef(0.3, Color.Gray) \'設置底邊框
rtHeader.Style.Padding.Bottom = 1 \'底端內容縮進1毫米
rtHeader.Style.FontSize = 8 \'字體大小為8磅
Doc.PageHeader = rtHeader \'作為頁眉使用
\'設置表格

Dim rt As New prt.RenderTable() \'定義一個表格對象
doc.Body.Children.Add(rt) \'將表格對象加入到報表中
rt.Style.GridLines.All = New prt.Linedef(0.5, Color.Black)  \'設置網格線
rt.CellStyle.Spacing.All = 1 \'內容距離網格線1毫米
\'設置表格主標題
rt.Cells(0,0).text = "傳票"
rt.Cells(0,0).SpanCols = 8 \'合併第一行全部單元格,用於顯示主標題
rt.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'主標題居中
rt.Cells(0,0).Style.Font = New Font("宋體", 18, FontStyle.Bold) \'設置主標題字體
rt.Rows(0).Style.Borders.All = New prt.LineDef(0, Color.White) \'去掉第一行的網格線
\'設置表格副標題
rt.Cells(1,0).SpanCols = 6 \'合併第二行全部單元格,用於顯示副標題
rt.Cells(1,6).SpanCols = 2
rt.Cells(1,0).text = "傳票號碼 : " & e.Form.Controls("VoucherNo").Value \'副標題
rt.Cells(1,6).text = "傳票日期 : " & e.Form.Controls("VoucherDate").Value \'副標題
rt.Cells(1,6).Style.Borders.Left = New prt.LineDef(0, Color.White) \'去掉第二行的網格線
rt.Cells(1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Left \'副標題內容居右
rt.Cells(1,6).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'副標題內容居右
rt.Rows(1).Style.Borders.All = New prt.LineDef(0, Color.White) \'去掉第二行的網格線
rt.Rows(1).Style.Borders.Bottom = New prt.Linedef  \'恢復第二行底端的網格線
rt.Rows(1).Height = 8 \'設置第二行的高度,拉和表格主體的距離.
rt.RowGroups(0,3).Header = prt.TableHeaderEnum.All  \'前三行作為表頭
\'設置表格內容
Dim ColNames As String() = New String(){"ItemName", "Particular", "CenterName", "CaseName", "CurrencyName", "Adjustment", "DebitInitial", "CreditInitial"}
Dim ColCaptions As String() = New String(){"科目名稱", "摘要說明", "部門", "專案", "幣別", "沖帳", "原幣借方金額", "原幣貸方金額"}
For c As Integer = 0 To ColNames.Length -1
    rt.Cells(2, c).Text = ColCaptions(c)
    If c = 6 OrElse c = 7 Then
        rt.Cells(3, c).Text = "[Format(Fields!" & ColNames(c) & ".Value, ""#,##0.00"")]" \'設置綁定表達式
        rt.Cells(3, c).Style.TextAlignHorz = prt.AlignHorzEnum.Right
    Else
        rt.Cells(3, c).Text = "[Fields!" & ColNames(c) & ".Value]" \'設置綁定表達式
    End If
Next
rt.RowGroups(3,1).DataBinding.DataSource = BindTables("Voucher.VoucherDetails") \'綁定到表
\'設置表格樣式
rt.RowGroups(2,1).Style.FontSize = 9
rt.RowGroups(2,1).Style.BackColor = Color.LightGray
rt.RowGroups(2,1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cols(0).Width = 20
rt.Cols(1).Width = 20
rt.Cols(2).Width = 20
rt.Cols(3).Width = 20
rt.Cols(4).Width = 12
rt.Cols(5).Width = 10
rt.Cols(6).Width = 25
rt.Cols(7).Width = 25
\'設置統計欄位

Dim sumDebitInitial As String
Dim sumCreditInitial As String
If Tables("Voucher.VoucherDetails").Rows.Count > 0 Then
    Tables("Voucher.VoucherDetails").Cols("DebitInitial").Visible = True
    Tables("Voucher.VoucherDetails").Cols("CreditInitial").Visible = True
    Dim c As Integer
    Dim r As Integer = Tables("Voucher.VoucherDetails").Rows.Count - 1
    c = Tables("Voucher.VoucherDetails").Cols("DebitInitial").Index
    sumDebitInitial = Format(Tables("Voucher.VoucherDetails").Aggregate(AggregateEnum.Sum, 0, c, r, c), "#,##0.00")
    c = Tables("Voucher.VoucherDetails").Cols("CreditInitial").Index
    sumCreditInitial = Format(Tables("Voucher.VoucherDetails").Aggregate(AggregateEnum.Sum, 0, c, r, c), "#,##0.00")
End If
Dim rc As Integer = rt.Rows.Count
rt.Cells(rc, 0).Text = "總計 : "
rt.RowGroups(rc, 1).Style.TextAlignHorz = prt.AlignHorzEnum.Right
rt.Cells(rc, 0).SpanCols = 6
rt.Cells(rc, 6).Text = sumDebitInitial
rt.Cells(rc, 7).Text = sumCreditInitial
rt.Cells(rc, 6).Style.Borders.Left = New prt.LineDef(0, Color.White)
rt.Cells(rc, 6).Style.Borders.Right = New prt.LineDef(0, Color.White)
rt.Rows(rc).Style.FontBold = True
rt.Rows(rc).Style.Borders.Left = New prt.LineDef(0, Color.White)
rt.Rows(rc).Style.Borders.Right = New prt.LineDef(0, Color.White)
rt.Rows(rc).Style.Borders.Bottom = New prt.LineDef(0, Color.White)
\'設置底端文本

Dim rtFooter As New prt.RenderText
rtFooter.Style.FontSize = 11
rtFooter.Style.Borders.Top = New prt.LineDef(1, Color.Gray)
rtFooter.Style.Padding.Top = 2
rtFooter.Text = "董事會代表 : " & "                                        " & "執行長 : " & vbcrlf & vbcrlf & "主管 : " & "                    " & "覆核 : " & "                    " & _
"會計 : " & "                    " & "出納 : " & "                    " & "製票 : " & User.Name & "    簽收 : "
Doc.PageFooter = rtFooter
\'紙張設定

Doc.PageSetting.PaperKind = 11    \'A5紙張
Doc.PageSetting.Landscape = True
Doc.PageSetting.LeftMargin = 5
Doc.PageSetting.RightMargin = 5
Doc.PageSetting.TopMargin = 10
Doc.PageSetting.BottomMargin = 10
Doc.Preview() \'預覽報表
Tables("Voucher.VoucherDetails").Cols("DebitInitial").Visible = False
Tables("Voucher.VoucherDetails").Cols("CreditInitial").Visible = False

--  作者:JoyGum
--  发布时间:2019/7/16 8:30:00
--  
老師有看到我上傳的材料嗎?如何做到按位打印的效果?
--  作者:有点蓝
--  发布时间:2019/7/16 9:15:00
--  
大概这样的效果,具体细节自己调整

Dim Names As List(Of String) = Tables("订单").DataTable.GetValues("产品")
Dim doc As New PrintDoc
Dim rt As New prt.RenderTable
rt.Cells(0,0).Text = "产品"
rt.Cells(0,0).SpanRows = 2
rt.Cells(0,1).Text = "订购次数"
rt.Cells(0,1).SpanRows = 2
rt.Cells(0,2).Text = "数量"
rt.Cells(0,2).SpanRows = 2
rt.Cells(0,3).Text = "金额"
rt.Cells(0,3).SpanCols = 12
Dim str() As String = {"十","亿","千","百","十","万","千","百","十","元","角","分"}
For i As Integer = 0 To str.Length -1
    rt.Cols(3+i).Width = 6
    rt.Cells(1,3+i).Text = str(i)
Next
For i As Integer = 0 To Names.Count -1
    rt.Cells(i+2,0).Text= Names(i)
    rt.Cells(i+2,1).Text = Tables("订单").DataTable.Compute("Count(日期)","产品=\'" & Names(i) & "\'")
    rt.Cells(i+2,2).Text = Tables("订单").DataTable.Compute("Sum(数量)","产品=\'" & Names(i) & "\'")
    Dim je As Double = Tables("订单").DataTable.Compute("Sum(金额)","产品=\'" & Names(i) & "\'")
    Dim jes  As String = Format(je,"#.00").Replace(".","").PadLeft(12)
    For j As Integer = 0 To jes.Length -1
        rt.Cells(i+2,3+j).Text = jes(j)
    Next
    \'rt.Cells(i+1,3).Text =
Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线
rt.CellStyle.Spacing.All = 1 \'内容距离网格线1毫米
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中
doc.Body.Children.Add(rt)
doc.Preview()

--  作者:JoyGum
--  发布时间:2019/7/16 11:48:00
--  
謝謝老師!我試試。