Foxtable(狐表)用户栏目专家坐堂 → [求助]怎样把SHEET1中的数据用FOXTABEL变成SHEET2结构的数据?


  共有2266人关注过本帖树形打印复制链接

主题:[求助]怎样把SHEET1中的数据用FOXTABEL变成SHEET2结构的数据?

帅哥哟,离线,有人找我吗?
大红袍
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/2/20 1:15:00 [显示全部帖子]

以前跟你说过类似的东西啊,循环每一行,提取对应的值出来啊。

 

Dim dlg As new OpenFileDialog
If dlg.ShowDialog = DialogResult.OK Then
    Dim book As new XLS.Book(dlg.FileName)
    Dim sheet As XLS.Sheet = book.Sheets(0)
    Dim sheet2 As XLS.Sheet = book.sheets(1)
    Dim idx As Integer = 1
    For i As Integer = 0 To sheet.Rows.Count - 1
        If sheet(i, 0).Text = "学号" Then
            For j As Integer = 2 To 9
                If sheet(i, j).Text > "" Then
                    sheet2(idx, 1).Value = sheet(i, j).Text
                    sheet2(idx, 0).Value = sheet(i+2, 0).Text
                    sheet2(idx, 2).Value = sheet(i+2, j).Text
                    idx += 1
                Else
                    Exit For
                End If
            Next
        End If
    Next
    book.Save(dlg.FileName)
    msgbox("OK")
End If

 


 回到顶部