DataTables("资产负债表汇总").DataRows.Clear
Dim aa As String
aa=vars("aa")
For Each file As String In filesys .GetFiles(ProjectPath & aa)
If file.EndsWith(".xls") OrElse file.EndsWith(".xlsx") Then
Dim Book1 As New XLS.Book(file)
Dim Sheet1 As XLS.Sheet = Book1.Sheets("资产负债表")
If sheet1(1,0).value = Nothing Then
MessageBox.Show( Sheet1(3,0).Value & "导入报表日期不符!")
Else
If Sheet1(1,0).Value = vars("cc") Then
Dim dr As DataRow = DataTables("资产负债表汇总").AddNew
Dim nms1() As String = {"项目","行次","年初数","年未数"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
Dim s1 As String = Sheet1(3,0).Value
Dim nn As Integer
Dim tt As Table = Tables("单位")
Dim i1 As Integer
nn=s1.Length
For i1 = 0 To nn
For i2 As Integer = 0 To tt.Rows.Count - 1
If s1.Substring(i1,4)= tt.Rows(i2)("单位") Then
s1 = s1.Substring(i1,2)
nn =0
Exit For
End If
Next
If nn = 0 Then
Exit For
End If
Next
For n As Integer = 5 To 54
Dim r As Row = Tables("资产负债表汇总").AddNew()
For m As Integer = 0 To nms1.Length - 1
r(nms1(m)) = Sheet1(n,m).Value
Next
r("日期") = Sheet1(1,0).Value
r("单位") = s1
Next
For n As Integer = 5 To 54
Dim r As Row = Tables("资产负债表汇总").AddNew()
For m As Integer = 0 To nms1.Length - 1
r(nms1(m)) = Sheet1(n,m+4).Value
Next
r("日期") = Sheet1(1,0).Value
r("单位") = s1
Next
DataTables("资产负债表汇总").DeleteFor("[行次] is null")
Else If Sheet1(1,0).Value <> vars("cc")Then
MessageBox.Show( Sheet1(3,0).Value & "导入报表日期不符!")
End If
End If
End If
Next
改成这样就行了,但MessageBox.Show( Sheet1(3,0).Value & "导入报表日期不符!")如何将Sheet1(3,0).Value改为该EXCEL表名?