我一直在收到类型&System; No。发生此错误的错误。它指向" Dim TheRange As Range = oSheet.Cells(1,1).Value" 我确实打破了,发现TheRange的价值不算什么......不确定我做错了什么,或者我看不到它的东西。
Dim OExcel As New Excel.Application
OExcel.Visible = False 'Put true if you want to see the excel application showing on the screen
Dim oBook As Excel.Workbook = OExcel.Workbooks.Open("C:\Users\cpushpa\Desktop\test.xlsx")
Dim oSheet As Excel.Worksheet = TryCast(oBook.Worksheets(1), Worksheet)
Dim TheRange As Range = oSheet.Cells(1, 1).Value
Dim Data As String = ""
For TheColumn As Integer = 1 To TheRange.Columns.Count
For TheRow As Integer = 1 To TheRange.Rows.Count
Data &= CType(oSheet.Cells(TheRow, TheColumn), Range).Value.ToString & ","
Next
Data = Data.TrimEnd(","c) & vbCrLf
Next
oBook.Close()
OExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(OExcel)
Using FileWriter As IO.StreamWriter = IO.File.CreateText("C:\Users\cpushpa\Desktop\DataTextFile.txt")
FileWriter.WriteLine(Data)
End Using
Process.Start("Notepad", "C:\Users\cpushpa\Desktop\DataTextFile.txt")