How to export data in excel file from sql server using c# code?

Total Post:134

Points:940
C# 
C#
 6106  View(s)
Ratings:
Rate this:
Hello Everyone,
I'm facing a problem since last night, Actually I want to export SQL Server table data in MS-Excel file but I don't have idea how do it. Please help me as soon as possible.

Thanks in advance!!
  1. Post:68

    Points:476
    Re: How to export data in excel file from sql server using c# code?

    Post is removed by the User.

  1. Post:68

    Points:476
    Re: How to export data in excel file from sql server using c# code?

    Hi Tanuj Kumar,
    Please check out this link.....
    http://www.mindstick.com/Blog/294/How%20to%20import%20or%20export%20SQL%20Server%20table%20data%20in%20MS%20Excel%20sheet%20using%20C%20Code

    It might be resolve this problem. You can also use MindStick DataCoverter to resolve this problem. It helps you to export and import data from different file format. To download MindStick DataConverter, please click here.

  1. Post:2

    Points:14
    Re: How to export data in excel file from sql server using c# code?

    Hi, MindStick DataConverter is really a very neat and straightforward software, but it seems it is stuck on version: 1.0.0.0.
    I hope there will be some additional improvements in the future, for example a support for newer XLSX file format.
    Nevertheless Tanuj you can try this C# Excel class library, I found it very helpful in spreadsheet to database communication tasks.

    // Load Excel file.
    ExcelFile workbook = ExcelFile.Load("Workbook.xlsx");
    // Select active worksheet from the file.
    ExcelWorksheet worksheet = workbook.Worksheets.ActiveWorksheet;
    // Extract the data from the worksheet to newly created DataTable.
    DataTable dataTable = worksheet.CreateDataTable(new CreateDataTableOptions()
    {
        StartRow = 0,
        StartColumn = 0,
        ColumnHeaders = true,
        ExtractDataOptions = ExtractDataOptions.StopAtFirstEmptyRow
    });

      Modified On Apr-03-2018 06:14:25 AM

Answer