I'm creating a program and it is paramount to its functionality that it can open->read->close a Microsoft Excel (.xlsx) file.
Now, i've searched the forums with the keyword "Excel" and found a lot of stuff in many programming languages, none of which were any use to me.
I should pinpoint that i'm not that good at programming as university takes all my times, but every summer (like this one) i really enjoy tackling my problems via programming. The reason im saying that, is that, as i love programming, any insight you could offer, any additional information will be much appreciate it. i do want to learn as much as possible.
What i've written so far is this:
Imports Excel Imports System.IO Public Class Form1 Dim stream As FileStream Dim excelReader As IExcelDataReader Dim i As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load stream = File.Open("C:\Book1.xlsx", FileMode.Open, FileAccess.Read) excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream) Dim result As DataSet = excelReader.AsDataSet() For i = 0 To result.Tables.Item(i).Columns.Count - 1 TextBox1.Text = TextBox1.Text & vbCrLf & result.Tables.Item(i).ToString Next i = 0 While excelReader.Read() excelReader.GetInt32(0) TextBox2.Text = TextBox2.Text & " " & excelReader.GetString(i) i = i + 1 End While excelReader.Close() End Sub End Class
I understand what a great disaster it is as a code. beyond stupidlike i could add
However this is the first time i am working with excel and i know nothing as far as excel-through-Vb.net is concerned.
P.S i've also imported one more file for excel but it is not shown in the code window cuz it was a downloaded file and i had to loaded it from the settings