Search code examples
sql-serverreporting-servicesexport-to-excel

Export SQL query to excel with multiple worksheets and custom headers


What I need to do is, a client wants to have a report in an excel doc with multiple worksheets with custom headers. I have tried SSRS 2008 Report Builder 2.0 but naming worksheets is not available with SSRS 2008 Report Builder 2.0. I have tried bcp in SQL Server Management Studio, but am not able to export it into multiple worksheets. I have put the queries into temp tables, is there a way to export those queries into the same excel doc but different worksheets with a different header for each worksheet.

Like thisenter image description here enter image description here enter image description here enter image description here

Notice how each worksheet has a different name and a different header.

Is this possible to do with SQL or is there a workaround for SSRS 2008 Report Builder 2.0?


Solution

  • You could use SQL Server Integration Services 2008R2 (SSIS) to do this. SSIS has an Excel Data Flow Destination that accepts a worksheet name as a parameter. You could construct your SSIS package to populate the various worksheets of a spreadsheet this way.