以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]报表  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=83735)

--  作者:kaiyu
--  发布时间:2016/4/15 15:18:00
--  [求助]报表

Dim Book As New XLS.Book("c:\\reports\\fs.xls")
Dim Sheet1 As XLS.Sheet = Book.Sheets(1)
For l As Integer = 0 To t.dataCols.count - 1
    sheet1(0,l).value = t.dataCols(l).Name
Next

For i As Integer = 0 To t.dataRows.Count - 1
    For j As Integer = 0 To t.dataCols.count - 1
        Dim s As String = t.DataCols(j).Name
        If t.DataCols(j).IsDate
            If t.DataRows(i)(s) = "#0001-01-01 0:00:00#"
                sheet1(i + 1,j).Value = Nothing
            Else
                sheet1(i + 1,j).Value = t.dataRows(i)(s)
              sheet1(i+1,j).NumberFormat = "yyyy-m-d" \'日期
最后这一句想实现导出到EXCEL中的显示日期格式,这句代码有问题,如果没有最后一句,打开EXCEL中看到的日期数据是整数.


--  作者:大红袍
--  发布时间:2016/4/15 15:20:00
--  

Dim Style As XLS.Style = Book.NewStyle() \'定义新样式
Style.Format = "yyyy-m-d"

 

--------


sheet1(i+1,j).Style = style