以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]导出时,时间列问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=122721)

--  作者:81538475
--  发布时间:2018/8/1 0:05:00
--  [求助]导出时,时间列问题
时间列为空值时,导出的值多事0.请问下应该怎么改
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)
    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
        Sheet(r+1,i).Value = t.rows(r)(lms(i))
    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


--  作者:有点甜
--  发布时间: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