Foxtable(狐表)用户栏目专家坐堂 → [求助]导出时,时间列问题


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

主题:[求助]导出时,时间列问题

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


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

Dim t = CurrentTable
Dim Book As New XLS.Book '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
Dim lms As new List(of String)
For Each c As Col In t.Cols
    If c.Visible = True
        lms.Add(c.Name)
        If c.IsDate Then
            Dim style As XLS.Style = book.NewStyle
            style.Format = "yyyy-MM-dd"
            sheet.Cols(lms.Count-1).Style = style
        End If
    End If
Next
For i As Integer = 0 To lms.Count-1
    Sheet(0,i).Value = lms(i)
Next
For r As Integer = 0 To t.Rows.Count-1 '填入数据
    For i As Integer = 0 To lms.Count-1
        If t.rows(r)(lms(i)) <> Nothing
            Sheet(r+1,i).Value = t.rows(r)(lms(i))
        End If
    Next
Next
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then
    Book.Save(dlg.FileName)
    Dim Proc As New Process
    Proc.File = dlg.FileName
    Proc.Start()
End If

 回到顶部