Foxtable(狐表)用户栏目专家坐堂 → 导出问题


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

主题:导出问题

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/9/23 13:48:00 [显示全部帖子]

Dim tbl As Table = Tables("查询_Table1")
Dim hdr As Integer = tbl.HeaderRows '获得表头的层数
Dim cnt As Integer
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
tbl.CreateSheetHeader(Sheet) '生成表头
Dim Style As XLS.Style = Book.NewStyle() '定义新样式
Style.Format = "yyyy-MM-dd" '设置样式的字体颜色


For c As Integer = 0 To tbl.Cols.Count - 1
    If tbl.Cols(c).Visible Then
        If tbl.Cols(c).IsDate Then
            Sheet.Cols(cnt).Style = Style
        ElseIf tbl.Cols(c).IsBoolean Then
            For r As Integer = 0 To tbl.Rows.Count - 1
                If tbl.Rows(r).IsNull(c) = False
                    sheet(r + hdr,cnt).value = IIF(tbl(r,c),"√","")
                End If
            Next
            Continue For
        End If
        For r As Integer = 0 To tbl.Rows.Count - 1
            If tbl.Rows(r).IsNull(c) = False
                sheet(r + hdr,cnt).value = tbl(r,c)
            End If
        Next
        cnt = cnt + 1
    End If
Next
Book.Save("d:\室内设计项目.xls")
Dim Proc As New Process
Proc.File = "d:\室内设计项目.xls"
Proc.Start()


 回到顶部