以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  sheet(4,3) 4变成循环的i 读取不出来数  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=109233)

--  作者:zhuangli515
--  发布时间:2017/11/7 13:58:00
--  sheet(4,3) 4变成循环的i 读取不出来数

For Each file As String In filesys .GetFiles("c:\\Data")
    If
file.EndsWith(".xls") OrElse file.EndsWith(".xlsx") Then
        Dim
Book As New XLS.Book(file)
        Dim
Sheet As XLS.Sheet = Book.Sheets(0)
        Dim
dr As DataRow = DataTables("员工").AddNew
       
dr("姓名") = sheet(4,1).Text
       
dr("部门") = sheet(5,1).text
       
dr("出生日期") = sheet(4,3).text
       
dr("雇佣日期") = sheet(5,3).text
       
dr("性别") = sheet(6,1).text
       
dr("职务") = sheet(6,3).text
       
dr("地址") = sheet(7,1).text
       
dr("家庭电话") = sheet(8,1).text
       
dr("办公电话") = sheet(8,3).text
       
dr("备注") = sheet(9,0).text
    End If
Next




sheet(4,3)  4变成循环的i 读取不出来数   如下:


For Each file As String In filesys .GetFiles("c:\\Data")

    If file.EndsWith(".xls") OrElse file.EndsWith(".xlsx") Then

        Dim Book As New XLS.Book(file)

        Dim Sheet As XLS.Sheet = Book.Sheets(0)

        Dim dr As DataRow = DataTables("表A").AddNew

        Dim i As Integer

        For i = 1 To 10 Step 1

            If  sheet(i,0).Value IsNot Nothing Then

                dr("表名") = file

                dr("标题") = sheet(0,0).Value

                dr("规格") = sheet(i,0).Text

                dr("报价") = sheet(i,2).Value

                dr("美元每米") = sheet(i,8).Value

                dr("利润点") = sheet(i,7).Value

            End If

        Next

        output.show(sheet(i,0).Value)

    End If

Next


--  作者:有点甜
--  发布时间:2017/11/7 14:44:00
--  

1、你excel文件的结构是怎样的?截图或者上传文件说明。

 

2、你为什么要循环读取?你excel里面有多行数据?上传具体例子说明。