Exporting to multiple worksheets using SSIS -
i'm starting out in ssis, , wondering if it's quite straightforward use 2 sql queries create 2 worksheets in 1 workbook using ssis, or whether should suggest way produce data.
yes, straightforward. can use same excel connection manager both , in 2 excel destinations, select "name of excel sheet".
if want create worksheets using oledb 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(); }
Comments
Post a Comment