以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  专业报表  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=26354)

--  作者:szxsxsj
--  发布时间:2012/12/1 12:03:00
--  专业报表

请问老师下面代码如何1、合计金额转换成大写格式

                            2、日期转换成YYYY年MM月DD日

              3、单价,金额列4舍5入保留2位小数

 

 

 

 

Dim doc As New PrintDoc \'定义一个报表
Dim ra As New prt.RenderTable
doc.PageSetting.PaperKind = 9 \'纸张类型改为A4
Dim x As Integer = 0 \'定义水平偏移参数
Dim y As Integer = 0 \'定义垂直偏移参数

Doc.PageSetting.LeftMargin = 0 \'设置左边距
Doc.PageSetting.RightMargin = 0 \'设置右边距
Doc.PageSetting.TopMargin = 0 \'设置上边距
Doc.PageSetting.BottomMargin = 0 \'设置下边距
doc.PageSetting.Landscape = False \'横向打印

Dim rx As prt.RenderText  \'定义一个文本对象
Dim CurRow As Row = Tables("出货单").Current

rx = new prt.RenderText
rx.Text =Tables("出货单"). Current("日期") rx.x = 44
rx.y = 24

 

 

doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = " 出货单号:    " & Tables("出货单").Current("出货单号")
rx.x = 25
rx.y = 18
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = "合计 (小写) : ¥" & Tables("出货单").Current("金额")
rx.x = 130
rx.y = 101
doc.body.Children.Add(rx)


rx = new prt.RenderText
rx.Text = "合计金额 (大写) : " & Tables("出货单").Current ("金额")
rx.x = 25
rx.y = 101


doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = "出货人:  "& Tables("出货单").Current("出货人")
rx.x = 25
rx.y = 117

doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = "顾客名称:  "& Tables("出货单").Current("顾客名称")
rx.x = 25
rx.y = 30
doc.body.Children.Add(rx)

 


 

Dim  rt As prt.RenderTable
rt = New prt.RenderTable
rt.Width = 170 \'表宽为150毫米
rt.Height = 60 \'表高为150毫米
rt.Rows.Count = 9 \'设置行数
rt.Cols.Count = 5 \'设置列数
rt.x=25
rt.y=38

rt.Cols(0).Width = 60
rt.Cols(1).Width = 17
rt.Cols(2).Width = 24
rt.Cols(3).Width = 25
rt.Cols(4).Width = 25

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 = "金额"


With Tables("发票.发票清单")
    For r As Integer = 0 To .Rows.Count - 1 \'遍历关联表每一行
        rt.Cells(r+1,0).Text = .rows(r)("品名规格")
        rt.Cells(r+1,1).Text = .rows(r)("单位")
        rt.Cells(r+1,2).Text = .rows(r)("数量")
        rt.Cells(r+1,3).Text = .rows(r)("单价")
        rt.Cells(r+1,4).Text = .rows(r)("金额")
      Next
End With
doc.Body.Children.Add(rt)

Doc.Preview() \'预览报表


--  作者:lin_hailun
--  发布时间:2012/12/1 12:14:00
--  
 1、合计金额转换成大写格式

 2、日期转换成YYYY年MM月DD日

 3、单价,金额列4舍5入保留2位小数


http://www.foxtable.com/help/topics/1345.htm


http://www.foxtable.com/help/topics/0360.htm


http://www.foxtable.com/help/topics/0281.htm


--  作者:szxsxsj
--  发布时间:2012/12/4 12:52:00
--  

谢谢,但我是初学者,还是不明白.希望老师能把代码插入示范给我看看.我加下去还不行,谢谢了!


--  作者:lin_hailun
--  发布时间:2012/12/4 13:10:00
--  
楼主参考一下写就好了。

Dim doc As New PrintDoc \'定义一个报表
Dim ra As New prt.RenderTable
doc.PageSetting.PaperKind = 9 \'纸张类型改为A4
Dim x As Integer = 0 \'定义水平偏移参数
Dim y As Integer = 0 \'定义垂直偏移参数

Doc.PageSetting.LeftMargin = 0 \'设置左边距
Doc.PageSetting.RightMargin = 0 \'设置右边距
Doc.PageSetting.TopMargin = 0 \'设置上边距
Doc.PageSetting.BottomMargin = 0 \'设置下边距
doc.PageSetting.Landscape = False \'横向打印

Dim rx As prt.RenderText  \'定义一个文本对象
Dim CurRow As Row = Tables("出货单").Current

rx = new prt.RenderText
rx.Text = Format(CDate(Tables("出货单"). Current("日期")), "yyyy年MM月dd日")

rx.x = 44
rx.y = 24

 

 

doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = " 出货单号:    " & Tables("出货单").Current("出货单号")
rx.x = 25
rx.y = 18
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = "合计 (小写) : ¥" & Math.Round2(CDbl(Tables("出货单").Current("金额")), 2)
rx.x = 130
rx.y = 101
doc.body.Children.Add(rx)


rx = new prt.RenderText
rx.Text = "合计金额 (大写) : " & CUNumber(Tables("出货单").Current ("金额"))
rx.x = 25
rx.y = 101


doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = "出货人:  "& Tables("出货单").Current("出货人")
rx.x = 25
rx.y = 117

doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = "顾客名称:  "& Tables("出货单").Current("顾客名称")
rx.x = 25
rx.y = 30
doc.body.Children.Add(rx)

 


 

Dim  rt As prt.RenderTable
rt = New prt.RenderTable
rt.Width = 170 \'表宽为150毫米
rt.Height = 60 \'表高为150毫米
rt.Rows.Count = 9 \'设置行数
rt.Cols.Count = 5 \'设置列数
rt.x=25
rt.y=38

rt.Cols(0).Width = 60
rt.Cols(1).Width = 17
rt.Cols(2).Width = 24
rt.Cols(3).Width = 25
rt.Cols(4).Width = 25

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 = "金额"


With Tables("发票.发票清单")
    For r As Integer = 0 To .Rows.Count - 1 \'遍历关联表每一行
        rt.Cells(r+1,0).Text = .rows(r)("品名规格")
        rt.Cells(r+1,1).Text = .rows(r)("单位")
        rt.Cells(r+1,2).Text = .rows(r)("数量")
        rt.Cells(r+1,3).Text = .rows(r)("单价")
        rt.Cells(r+1,4).Text = .rows(r)("金额")
      Next
End With
doc.Body.Children.Add(rt)

Doc.Preview() \'预览报表


--  作者:szxsxsj
--  发布时间:2012/12/4 15:04:00
--  

解决了,感谢!