Foxtable(狐表)用户栏目专家坐堂 → 导出excel列属性


  共有3994人关注过本帖树形打印复制链接

主题:导出excel列属性

帅哥哟,离线,有人找我吗?
xrrzzy56
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:10 积分:147 威望:0 精华:0 注册:2014/7/4 14:51:00
导出excel列属性  发帖心情 Post By:2014/7/4 15:07:00 [只看该作者]

从“表A”中直接导出excel,导出后"日期"列为数字,需要是日期格式("yyyy-MM-dd"),求老师指导如何实现?
代码如下:
Dim tbl As Table = Tables("表A") 
Dim hdr As Integer = tbl.HeaderRows 
Dim Book As New XLS.Book Dim Sheet As XLS.Sheet = Book.Sheets(0) 
Dim Proc As New Process 
tbl.CreateSheetHeader(Sheet,0,0,False) 
For c As Integer = 0 To tbl.Cols.Count - 1 
For r As Integer = 0 To tbl.Rows.Count - 1 
sheet(r + hdr,c).value = tbl(r,c) 
Next 
Next 
Book.Save("c:\reports\test.xls") 
  Proc.File = "c:\reports\test.xls" Proc.Start()

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/7/4 15:14:00 [只看该作者]

Dim tbl As Table = Tables("表A")
Dim hdr As Integer = tbl.HeaderRows
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim Proc As New Process
tbl.CreateSheetHeader(Sheet,0,0,False)
Dim st As XLS.Style = Book.NewStyle() '定义新样式st.Format = "yyyy-MM-dd"
For c As Integer = 0 To tbl.Cols.Count - 1
    If tbl.Cols(c).IsDate Then
        For r As Integer = 0 To tbl.Rows.Count - 1
            sheet(r + hdr,c).value = tbl(r,c)
            sheet(r + hdr,c).Style = st
        Next
    Else
        For r As Integer = 0 To tbl.Rows.Count - 1
            sheet(r + hdr,c).value = tbl(r,c)
        Next
    End If
Next
Book.Save("c:\reports\test.xls")
Proc.File = "c:\reports\test.xls"
Proc.Start()

 回到顶部
帅哥哟,离线,有人找我吗?
xrrzzy56
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:10 积分:147 威望:0 精华:0 注册:2014/7/4 14:51:00
  发帖心情 Post By:2014/7/4 15:22:00 [只看该作者]

谢了图片点击可在新窗口打开查看

 回到顶部