|
-
May 23rd, 2008, 06:01 AM
#1
Reading data from Excel table
Hi,
Maybe do you know how how to read data from Excel (I have one worksheet for all .xls documents, and and table with columns and rows to retrieve info from them).
I would be very grateful if you help me, and thanks in advance
-
May 23rd, 2008, 01:13 PM
#2
Re: Reading data from Excel table
Try to use OleDB to get data from excel sheet. Check http://www.connectionstrings.com and you will see how to connect to excel file.
The difficulty is that you have no idea how difficult it is.
.Net 3.5/VS 2008
-
May 29th, 2008, 02:01 AM
#3
Re: Reading data from Excel table
While reading with C# from Word table, there is doc.Tables[1].Rows[i].Cells[j].Value property. Maybe do you know somethihg similat to read from Excel table?
-
May 29th, 2008, 03:30 PM
#4
Re: Reading data from Excel table
Code:
//Open excel file
DataSet dsRecords = new DataSet();
string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=ExcelDocument.xls;Extended Properties=Excel 8.0;";
OleDbDataAdapter daExcel = new OleDbDataAdapter("SELECT * FROM [SomeWorksheet$]", strConn);
daExcel.Fill(dsRecords, "records");
for (int a = 0; a < dsRecords.Tables[0].Rows.Count; a++)
{
string someString = dsRecords.Tables[0].Rows[a][0].ToString().Trim();
}
-
May 30th, 2008, 01:33 AM
#5
Re: Reading data from Excel table
Thanks a lot. It's very useful.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|