我正在尝试使用Telerik.Windows.Documents.Spreadsheet读取电子表格。 没有引发错误,但是它不加载任何数据和0个工作表。 我错过了重要的一步吗?
Dim workbook As New Workbook()
Dim FilePath As String = "myFile.xlsx"
Dim webClient As New WebClient()
AddHandler webClient.OpenReadCompleted, Sub(sender, eventArgs)
Dim formatProvider As New XlsxFormatProvider()
workbook = formatProvider.Import(eventArgs.Result)
End Sub
webClient.OpenReadAsync(New Uri(FilePath))
Dim worksheet As Worksheet = workbook.Sheets(0) 'No sheet at index 0
答案 0 :(得分:0)
这可行!
Dim workbook As New Workbook()
Dim fileName As String = "myFile.xlsx"
If Not File.Exists(fileName) Then
Throw New FileNotFoundException([String].Format("File {0} was not found!", fileName))
End If
Dim formatProvider As IWorkbookFormatProvider = New XlsxFormatProvider()
Using input As Stream = New FileStream(fileName, FileMode.Open)
workbook = formatProvider.Import(input)
End Using