H
Hardy Wang
Hi all,
I have following code to read Excel content into a DataSet
string connection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
fileName + ";Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1;\"";
OleDbConnection conn = new OleDbConnection(connection);
try {
DataSet ds = new DataSet();
conn.Open();
OleDbDataAdapter oAdapter = new OleDbDataAdapter("select * from
[Main$]", conn);
oAdapter.Fill(ds);
conn.Close();
} catch {
}
One of the column is phone number, and some cells of this column are marked
as "The number in this cell is formatted as text or proceeded by
apostrophe", I can find a small green triangle at top-left corner of the
cell, then values from these cells in DataSet are blank
Is there any trick how to write connection string or how to read Excel file?
Thanks!
I have following code to read Excel content into a DataSet
string connection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
fileName + ";Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1;\"";
OleDbConnection conn = new OleDbConnection(connection);
try {
DataSet ds = new DataSet();
conn.Open();
OleDbDataAdapter oAdapter = new OleDbDataAdapter("select * from
[Main$]", conn);
oAdapter.Fill(ds);
conn.Close();
} catch {
}
One of the column is phone number, and some cells of this column are marked
as "The number in this cell is formatted as text or proceeded by
apostrophe", I can find a small green triangle at top-left corner of the
cell, then values from these cells in DataSet are blank
Is there any trick how to write connection string or how to read Excel file?
Thanks!