This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Microsoft XML > March 2006 > Excel into XML
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hi,
I have to convert Excel -> XML. I have to do it using OleDb.
OleDbConnection con = new OleDbConnection();
con.ConnectionString = @"Provider =
Microsoft.Jet.OLEDB.4.0; Data Source = C:\test.xls;" +
"Extended Properties=\"Excel 8.0\";";
OleDbCommand com = new OleDbCommand("SELECT * FROM
[Sheet1$]", con);
OleDbDataAdapter adapter = new OleDbDataAdapter(com);
DataSet ds = new DataSet();
try
{
con.Open();
adapter.Fill(ds);
this.dataGrid1.DataSource = ds.Tables[0];
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
}
My problem is that I will not know quantity of Sheets and they name.
So I need something like in SLQServer "SELECT * FROM sysobjects" to get
all sheets.
Thank you,
Ion.
| |
| Sinan Ussakli 2006-03-15, 10:17 pm |
| Please try microsoft.public.office.developer.office.sdks forum for this,
Thanks
--
Sinan Ussakli
WebData XML
Microsoft
"Ion" wrote:
> Hi,
>
> I have to convert Excel -> XML. I have to do it using OleDb.
>
>
> OleDbConnection con = new OleDbConnection();
> con.ConnectionString = @"Provider =
> Microsoft.Jet.OLEDB.4.0; Data Source = C:\test.xls;" +
> "Extended Properties=\"Excel 8.0\";";
> OleDbCommand com = new OleDbCommand("SELECT * FROM
> [Sheet1$]", con);
>
> OleDbDataAdapter adapter = new OleDbDataAdapter(com);
> DataSet ds = new DataSet();
> try
> {
> con.Open();
> adapter.Fill(ds);
> this.dataGrid1.DataSource = ds.Tables[0];
> }
> catch(Exception ex)
> {
> MessageBox.Show(ex.Message);
> }
> finally
> {
> con.Close();
> }
>
> My problem is that I will not know quantity of Sheets and they name.
> So I need something like in SLQServer "SELECT * FROM sysobjects" to get
> all sheets.
>
> Thank you,
> Ion.
>
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|