以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  逻辑列如何excel导入  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=71963)

--  作者:WUZHAN
--  发布时间:2015/7/21 14:42:00
--  逻辑列如何excel导入

合并数据代码,如果有逻辑列,EXCEL 中  是 true 和false ,请问老师如何导入狐表

Dim Book As New XLS.Book("c:\\test\\订单.xls")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("订单").StopRedraw()
Dim nms() As String = {"编号","产品","客户","雇员","单价","折扣","数量","日期"}
For n As Integer = 1 To Sheet.Rows.Count -1
    Dim bh As String = sheet(n,0).Text
    Dim dr As DataRow = DataTables("订单").Find("编号 = \'" & bh & "\'")
    If dr Is Nothing Then \'如果不存在同编号的订单
        dr =  DataTables("订单").AddNew()
    End If
    For m As Integer = 0 To nms.Length - 1
        dr(nms(m)) = Sheet(n,m).Value
    Next
Next
Tables("订单").ResumeRedraw()


--  作者:大红袍
--  发布时间:2015/7/21 14:50:00
--  
For m As Integer = 0 To nms.Length - 1
    If DataTables("订单").DataCols(nms(m)).IsBoolean Then
        If Sheet(n,m).Value = "true" Then
            dr(nms(m)) = True
        Else
        
    dr(nms(m)) = False
        End If

    Else
        dr(nms(m)) = Sheet(n,m).Value
    End If
Next