以文本方式查看主题

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

--  作者:xybcxh
--  发布时间:2018/8/15 16:34:00
--  [求助]
导入合并表,出现:该字符串未被识别为有效的布尔值。不能在 是否报废 列中存储 <0>。所需类型是 Boolean。错误。

导入编码:

Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog =DialogResult.OK Then
    Dim t As Table = Tables("杭康设备总表")
    t.StopRedraw()
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    Dim newcount As Integer = 0
    Dim oldcount As Integer = 0
    For n As Integer = 1 To Sheet.Rows.Count -1
        Dim r As DataRow = t.DataTable.Find("序号 = \'" & sheet(n, 0).text & "\'")
        If r Is Nothing Then
            r = t.DataTable.AddNew()
            newcount += 1
        Else
            oldcount += 1
        End If
        For i As Integer = 0 To sheet.Cols.Count -1
            Dim cname As String = sheet(0, i).text
            If t.Cols.Contains(cname) Then
                r(cname) = sheet(n, i).Text
 

           End If
        Next
    Next
    msgbox("新增" & newcount & "    " & "更新旧数据" & oldcount)
    t.ResumeRedraw()
End If


从原表导出的编码 :

导出

Dim flg As New SaveExcelFlags

flg.RowNumber = False

flg.CellStyle = True

Flg.VisibleOnly = True

Tables("杭康设备总表").SaveExcel("d:\\杭康设备(修检校)\\设备总表(临时文件)\\" & Date .Today & " 杭康设备.xls","杭康设备总表",flg)

Dim Proc As New Process

Proc.File = "d:\\杭康设备(修检校)\\设备总表(临时文件)\\" & Date .Today & " 杭康设备.xls"

Proc.Start()

是否报废”列是逻辑列,Xlsx表上单元格显示是  FALSE ),不知要怎么改?请老师帮助。


--  作者:有点甜
--  发布时间:2018/8/15 16:40:00
--  
Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog =DialogResult.OK Then
    Dim t As Table = Tables("杭康设备总表")
    t.StopRedraw()
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    Dim newcount As Integer = 0
    Dim oldcount As Integer = 0
    For n As Integer = 1 To Sheet.Rows.Count -1
        Dim r As DataRow = t.DataTable.Find("序号 = \'" & sheet(n, 0).text & "\'")
        If r Is Nothing Then
            r = t.DataTable.AddNew()
            newcount += 1
        Else
            oldcount += 1
        End If
        For i As Integer = 0 To sheet.Cols.Count -1
            Dim cname As String = sheet(0, i).text
            If t.Cols.Contains(cname) Then
                If t.Cols(cname).IsBoolean Then
                    If sheet(n, i).Text = 1 OrElse sheet(n, i).Text = "true" Then
                        r(cname) = True
                    Else
                        r(cname) = False
                    End If
                Else
                    r(cname) = sheet(n, i).Text
                End If
            End If
        Next
    Next
    msgbox("新增" & newcount & "    " & "更新旧数据" & oldcount)
    t.ResumeRedraw()
End If

--  作者:xybcxh
--  发布时间:2018/8/15 17:05:00
--  
.NET Framework 版本:2.0.50727.5420
Foxtable 版本:2018.7.28.1
错误所在事件:窗口,主窗体,导入,Click
详细错误信息:
从字符串“”到类型“Date”的转换无效。

--  作者:有点甜
--  发布时间:2018/8/15 17:08:00
--  
Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog =DialogResult.OK Then
    Dim t As Table = Tables("杭康设备总表")
    t.StopRedraw()
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    Dim newcount As Integer = 0
    Dim oldcount As Integer = 0
    For n As Integer = 1 To Sheet.Rows.Count -1
        Dim r As DataRow = t.DataTable.Find("序号 = \'" & sheet(n, 0).text & "\'")
        If r Is Nothing Then
            r = t.DataTable.AddNew()
            newcount += 1
        Else
            oldcount += 1
        End If
        For i As Integer = 0 To sheet.Cols.Count -1
            Dim cname As String = sheet(0, i).text
            If sheet(n, i).Text > "" AndAlso t.Cols.Contains(cname) Then
                If t.Cols(cname).IsBoolean Then
                    If sheet(n, i).Text = 1 OrElse sheet(n, i).Text = "true" Then
                        r(cname) = True
                    Else
                        r(cname) = False
                    End If
                ElseIf t.Cols(cname).Isdate Then
                    r(cname) = sheet(n, i).Text
                Else
                    r(cname) = sheet(n, i).Text
                End If
            End If
        Next
    Next
    msgbox("新增" & newcount & "    " & "更新旧数据" & oldcount)
    t.ResumeRedraw()
End If

--  作者:xybcxh
--  发布时间:2018/8/15 17:26:00
--  
是不是借出日期列的问题?“2018-03-09 11:20:00”有时,分,秒的。。。
--  作者:有点甜
--  发布时间:2018/8/15 17:27:00
--  
以下是引用xybcxh在2018/8/15 17:26:00的发言:
是不是借出日期列的问题?“2018-03-09 11:20:00”有时,分,秒的。。。

 

现在报什么错?没有把时间合并进来?


--  作者:有点甜
--  发布时间:2018/8/15 17:31:00
--  

或者换一种思路,如

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=114559&skin=0

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=106892&skin=0

 


--  作者:xybcxh
--  发布时间:2018/8/16 8:15:00
--  回复:(xybcxh)[求助]
昨天5点多下班了,没有看到回帖,晚上到家,家里的电脑坏了。又重装了系统。。今天在单位做了测试(后面经修改的代码),已经完全好了。谢谢有点甜 老师。谢谢!