none
Export data sql server 2008 to excel

    Question

  • Please can you help me, code Export Excel from: (Export data sql server 2008 to excel many sheet, each row in datagridvew export one sheet excel, n row in datagridview = n sheet excel, note: export many sheets), i am using VS c# 2010, offices 2007, winform. if you can help for me example demo. skype:dmc_dongthap. Email:phuongktdmc@yahoo.com.vn. Thanks you very much.
    Friday, July 26, 2013 4:51 PM

Answers

  • Hi Dongthap,

    From your description, you want to export your report to multiple worksheets when exporting report to Microsoft Excel, one row one worksheet, right? In Reporting Services, when exporting report to excel, if we don’t add page breaks to rectangle, data regions, or groups within data regions for a report, then all the report contents will be exported into one worksheet. If we add page break for the report manually, then the report will be exported into multiple worksheets. So in your scenario, you can add page break on the detail group, so that each page display only one row, and when exporting it to Excel, each row will display on separate worksheet. For detail information about how to add page break, please see:
    How to: Add a Page Break (Reporting Services)

    If I have anything misunderstood, please point it out.

    Regards,


    Charlie Liao
    TechNet Community Support

    Monday, July 29, 2013 3:43 AM
    Moderator

All replies

  • Go through below link may helps you assuming that you are not asking for .NET code as this is SQL Server Forum..

    http://stackoverflow.com/questions/9086880/t-sql-export-to-new-excel-file

    Friday, July 26, 2013 5:44 PM
  • This is more complicated that it seems, there is an article that I found that suggest a method with code in c# to do such an export and it works like magic. The code exports a dataset (or Datatable) in the XML format of Excel, and then opens the file in an Excel application instance to save it in .xls or xlsx format. It seems to be the only method that works really well. The only bug I found is that it couldn't export uniqueidentifier columns but I just added the proper code and was perfect....

    Sorry I don't have the link on hand but with a bit Google you should find it.

    Friday, July 26, 2013 5:52 PM
  • Hi Dongthap,

    From your description, you want to export your report to multiple worksheets when exporting report to Microsoft Excel, one row one worksheet, right? In Reporting Services, when exporting report to excel, if we don’t add page breaks to rectangle, data regions, or groups within data regions for a report, then all the report contents will be exported into one worksheet. If we add page break for the report manually, then the report will be exported into multiple worksheets. So in your scenario, you can add page break on the detail group, so that each page display only one row, and when exporting it to Excel, each row will display on separate worksheet. For detail information about how to add page break, please see:
    How to: Add a Page Break (Reporting Services)

    If I have anything misunderstood, please point it out.

    Regards,


    Charlie Liao
    TechNet Community Support

    Monday, July 29, 2013 3:43 AM
    Moderator