有时在运行下面的代码时会导致IErrorInfo.GetDescription failed with E_FAIL(0x80004005)
调用excelFile.WorksheetNoHeader(0)
.
它似乎不依赖于 excel 文件,一个文件可以读取一次,下一次不读取。
任何想法可能是什么原因?
Public Overrides Function GetImportDataAsDataTable() As DataTable
Dim dataTable = New DataTable
dataTable.BeginLoadData()
Try
Dim excelFile = New ExcelQueryFactory(FileFullPath)
For Each importDataRow In excelFile.WorksheetNoHeader(0)
If dataTable.Columns.Count = 0 Then
For i = 1 To importDataRow.Count
dataTable.Columns.Add(New DataColumn())
Next
End If
Dim dataRow = dataTable.NewRow
dataRow.ItemArray = importDataRow.ToArray
dataTable.Rows.Add(dataRow)
Next
Finally
dataTable.EndLoadData()
End Try
Return dataTable
End Function