以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]打印日期格式问题?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=67795)

--  作者:bigeng
--  发布时间:2015/5/3 9:38:00
--  [求助]打印日期格式问题?
过磅单如何实现如下格式     日期
图片点击可在新窗口打开查看此主题相关图片如下:过磅单.jpg
图片点击可在新窗口打开查看
:2015年5月2日   出厂时间为:2015-05-02 08:31:12

参照甜版给修改的凭证日期代码:
Dim doc As PrintDoc = e.Form.GernatePrintDoc()
Dim d As Date
For Each c As object In Doc.Body.Children
    If c.Gettype.Name Like "*Table*" Then
        Dim t As prt.RenderTable = c
        t.Rows(0).Height = 10
        t.Rows(0).Style.BackColor = Color.white
        t.Rows(0).Style.Font = New Font("宋体", 12, FontStyle.Bold) \'设置字体
        For i As Integer = 0 To t.Cols.Count - 1
            t.Cells(0,i).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        Next
    Else If c.Gettype.name Like "*Text*" AndAlso Date.TryParse(c.text,d) Then
        c.text = Format(cdate(c.text), "yyyy年MM月dd日")
    End If
Next
doc.Preview

--  作者:sloyy
--  发布时间:2015/5/3 13:05:00
--  
你想问什么问题?
--  作者:大红袍
--  发布时间:2015/5/3 20:45:00
--  

 加入判断即可,比如

 

Dim doc As PrintDoc = e.Form.GernatePrintDoc()
Dim d As Date
For Each c As object In Doc.Body.Children
    If c.Gettype.Name Like "*Table*" Then
        Dim t As prt.RenderTable = c
        t.Rows(0).Height = 10
        t.Rows(0).Style.BackColor = Color.white
        t.Rows(0).Style.Font = New Font("宋体", 12, FontStyle.Bold) \'设置字体
        For i As Integer = 0 To t.Cols.Count - 1
            t.Cells(0,i).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        Next
    Else If c.Gettype.name Like "*Text*" AndAlso Date.TryParse(c.text,d) Then
        If c.Text.Length < 11 Then
            c.text = Format(cdate(c.text), "yyyy年MM月dd日")
        Else
            c.text = Format(cdate(c.text), "yyyy年MM月dd日 HH时mm分dd秒")
        End If

    End If
Next
doc.Preview

 


--  作者:bigeng
--  发布时间:2015/5/4 12:02:00
--  
好的,谢谢!