Good day folks,

lines = IO.File.ReadAllLines(txt_Source.Text)

I have here a line of code which reads a text file and save it to an array, It works well. But I wanna ask if there is anything like this code that can be use to read a excel file? Something like this :

lines = IO.File.ReadAllLines(excel.xls)

Any response will be highly appreciated :)

Recommended Answers

All 7 Replies

Click Here for some example code.

I already have that code. I'm just wondering if I can read an excel file by using a single line like what I've said above.

BTW, thanks bro :)

Well, personally, I have some sort of utility class with methods which handle all my Excel needs.

You can't read an Excel file line by line with a simple reader. You can

  1. create an Excel Application object and access it that way or
  2. use ADO or OleDb objects to access the data like a database

Using the first method allows you to access the Excel data on a cell by cell basis. Using the second method allows you to access the data row by row as long as the data is in tabular form (where every row is in the same format).

Thanks folks :) I'm currently using Oledb. BTW, nice explanation Jim.

You might want to have a look at this thread

Thanks Jim, it's a very informative one. Nice guide

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.