Advertisement
Advertisement
| 05.09.2008 at 09:03AM PDT, ID: 23389888 | Points: 500 |
|
[x]
Attachment Details
|
||
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 05.09.2008 at 09:55AM PDT, ID: 21534682 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: |
private void Test()
{
String filename = @"Bob's Data";
String listname = @"Bob's Data";
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename + ";Extended Properties=Excel 8.0");
try
{
con.Open();
DataSet myDataSet = new DataSet();
OleDbDataAdapter myCommand = new OleDbDataAdapter(" SELECT * FROM [" + listname + "$]", con);
myCommand.Fill(myDataSet);
con.Close();
foreach (DataRow myDataRow in myDataSet.Tables[0].Rows)
{
Object[] cells = myDataRow.ItemArray;
foreach (object cellContent in cells)
{
string cellText = cellContent.ToString();
cellText = cellText.Replace("\n", "|");
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
con.Close();
}
}
|