以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  导出日期不正确  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=131282)

--  作者:lihe60
--  发布时间:2019/2/22 9:36:00
--  导出日期不正确
1、导出的日期格式不正确
2、列顺序不正确
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目3.foxdb


--  作者:有点蓝
--  发布时间:2019/2/22 10:52:00
--  
Dim tbl As Table = Tables("表A")
Dim hdr As Integer = tbl.HeaderRows \'获得表头的层数
Dim cnt As Integer
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)

Dim Style As XLS.Style = Book.NewStyle() \'定义新样式
style.font = New Font("Arial",11) \',FontStyle.Bold Or FontStyle.Underline)
style.AlignHorz = XLS.AlignHorzEnum.Center
style.AlignVert = XLS.AlignVertEnum.Center
Style.BorderTop = XLS.LineStyleEnum.Thin
Style.BorderBottom = XLS.LineStyleEnum.Thin
Style.BorderLeft = XLS.LineStyleEnum.Thin
Style.BorderRight = XLS.LineStyleEnum.Thin
Style.BorderColorTop = Color.black
Style.BorderColorBottom = Color.black
Style.BorderColorLeft = Color.black
Style.BorderColorRight = Color.black

Dim St2 As XLS.Style = Book.NewStyle() \'定义新样式
st2.font = New Font("Arial",11) \',FontStyle.Bold Or FontStyle.Underline)
St2.BorderTop = XLS.LineStyleEnum.Thin
St2.BorderBottom = XLS.LineStyleEnum.Thin
St2.BorderLeft = XLS.LineStyleEnum.Thin
St2.BorderRight = XLS.LineStyleEnum.Thin
St2.BorderColorTop = Color.black
St2.BorderColorBottom = Color.black
St2.BorderColorLeft = Color.black
St2.BorderColorRight = Color.black
St2.Format = "yyyy-MM-dd"

tbl.CreateSheetHeader(Sheet) \'生成表头
Dim c As Integer =0
For Each c1 As Col In tbl.cols
    If c1.Visible Then
        For r As Integer = 0 To tbl.Rows.Count - 1
            sheet(r + hdr,cnt).value = tbl.Rows(r)(c1.Name)
            If c1.IsDate Then
                sheet(r + hdr,cnt).style = St2
            Else
                sheet(r + hdr,cnt).style = Style
            End If
            
        Next
        cnt = cnt + 1
        c=c+1
    End If
Next
c=0
For c=0 To Sheet.Cols.Count - 1
    Sheet(0, c).style = style
Next

Book.Save("e:\\问题\\test.xls")
Dim Proc As New Process
Proc.File = "e:\\问题\\test.xls"
Proc.Start()