Question : how can I read more then one cell an excel file in vb.net

Hi,  how can you read the contents in say cell ( A1, A2)   and then move to the next line and read the next set of cells  ( B1, B2)  I am  currently useing Vs 2008 and Excel 2007.

 The code i am currently useing to read a text file  in vb.net is

mastObj1 = stnObj.Masters(System.IO.File.ReadAllLines("C:\test.txt")(0))

Thanks

Answer : how can I read more then one cell an excel file in vb.net

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
To read cell(s) in the worksheet,

Excel.Sheets xlsheets = wb.Sheets; //Get the sheets from workbook
Excel.Worksheet excelWorksheet = (Excel.Worksheet)xlsheets[1]; //Select the first sheet
Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range("B4:FZ4", Type.Missing); //Select a range of cells
Excel.Range excelCell2 = (Excel.Range)excelWorksheet.get_Range("A5:A5", Type.Missing); //Select a single cell
Console.WriteLine(excelCell2.Cells.Value2.ToString()); //Print the value of the cell for a single cell selection
System.Array myvalues = (System.Array)excelCell.Cells.Value2; //Assign it to an array
string[] strArray = ConvertToStringArray(myvalues); //Convert array into String array
foreach (string str in strArray)
Console.WriteLine(" Text in Cell " + str); //Loop through the array to print the values in the cell 
Random Solutions  
 
programming4us programming4us