Exporting to multiple worksheets using SSIS

前端 未结 1 1114
你的背包
你的背包 2021-01-26 11:26

I\'m just starting out in SSIS, and I was just wondering if it\'s quite straightforward to use 2 SQL queries to create 2 worksheets in 1 workbook using SSIS, or whether I should

相关标签:
1条回答
  • 2021-01-26 11:36

    Yes, this is very straightforward. You can use the same excel connection manager for both and in the two Excel destinations, you just select "Name of the Excel sheet".

    If you want to create the worksheets using OLEDB you could do something like:

            string destination = "c:\myfile.xls";
    
            using ( OleDbConnection conn = new OleDbConnection( 
                String.Format( "provider=Microsoft.Jet.OLEDB.4.0; Data Source='{0}';"
                 + "Extended Properties='Excel 8.0;HDR=YES;'", destination ) ) )
            {
                conn.Open();
    
                using ( OleDbCommand cmd = new OleDbCommand( "CREATE TABLE [Sheet1$]([Column1] VARCHAR(255),"
                    +"[Column2] DATE,[Column3] INTEGER,[Column4] LONGTEXT)", conn ) )
                    cmd.ExecuteNonQuery();
    
    
                  using ( OleDbCommand cmd = new OleDbCommand( "CREATE TABLE [Sheet2$]([Column1] VARCHAR(255),"
                    +"[Column2] DATE,[Column3] INTEGER,[Column4] LONGTEXT)", conn ) )
                    cmd.ExecuteNonQuery();
    
            }
    
    0 讨论(0)
提交回复
热议问题