VB.Net/Windows System/Excel
Версия от 16:40, 26 мая 2010; (обсуждение)
Load Excel to edit xlsx file
Module Module1
Sub Main()
Dim file As String = "Data.xlsx"
Try
Dim row, col, finalRow, finalCol As Integer
Dim xl = CreateObject("Excel.application")
xl.Workbooks.Open(file)
xl.Worksheets("Sheet1").activate()
finalRow = xl.ActiveSheet.UsedRange.Rows.Count
finalCol = xl.ActiveSheet.UsedRange.Columns.Count
Dim vals(finalRow, finalCol) As String
For row = 1 To finalRow
For col = 1 To finalCol
vals(row, col) = _
Str(xl.ActiveSheet.Cells(row, col).Value)
Console.WriteLine(row)
Console.WriteLine(col)
Console.WriteLine(vals(row, col))
Next col
Next row
xl.Workbooks.Close()
xl = Nothing
Catch ex As Exception
MsgBox("Unable to read spreadsheet")
End Try
End Sub
End Module