以前跟你说过类似的东西啊,循环每一行,提取对应的值出来啊。
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