samedi 9 janvier 2016

C# .NET - Writing to an XLST file without OLEDB

Vote count: 0

I would like to know if there is any way I can easly create/write to an XLST file without having the Microsoft OLEDB driver installed.

Basically I've a file with all the inserts that need to be inserted like:

insert into TABLE (x,y,z) values (1,2,3)

I've already loaded all the insert string and I would like to know if there is any easy way to create an Excel file with multiple sheets (one for each table) and all the data.

So far I've this:

    public void WriteToXLST(SQLStructure oStructure, string sFilenamePath)
    {

        string connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.15.0;" +
                "Data Source={0};Extended Properties='Excel 15.0;HDR=YES;IMEX=0'", sFilenamePath);

        using (OleDbConnection cn = new OleDbConnection(connectionString))
        {
            cn.Open();

            foreach (string sInsertString in oStructure.InsertsList)
            {
                OleDbCommand cmd1 = new OleDbCommand(sInsertString, cn);
                cmd1.ExecuteNonQuery();
            }

            cn.Close();

        }

    }

The problem is that I do want this to run without the need of instaling the OLEDB.Do you guys have any idea on how to do this?

Thank you!

asked 47 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



C# .NET - Writing to an XLST file without OLEDB

Aucun commentaire:

Enregistrer un commentaire