none
How To Insert system.data.DataTable in Excel Work Sheet RRS feed

  • Question

  • How To Insert system.data.DataTable in Excel Work Sheet 

    i don't Want to enter Data Cell by Cell , i want to load At Once 


    • Moved by CoolDadTx Tuesday, September 23, 2014 5:30 PM Office related
    Tuesday, September 23, 2014 9:58 AM

All replies

  • Try the link

    http://www.gemboxsoftware.com/support/articles/import-export-datatable-xls-xlsx-ods-csv-html-net


    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora


    • Edited by RohitArora Tuesday, September 23, 2014 10:06 AM
    Tuesday, September 23, 2014 10:05 AM
  • i want to do this by using microsoft.office.interop.Excel Only

    Tuesday, September 23, 2014 10:17 AM
  • check 

    http://www.dotnetspider.com/resources/27875-DataTable-Excel-With-Bulk-Insert.aspx


    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Tuesday, September 23, 2014 11:07 AM
  • It First Enter All Columns And Then Loop All Rows And Insert Values Cell by Cell

    i Have to Insert Table At Once Not cell by Cell

    ie WrkSheet.dataTable = MyDataTable 

    Tuesday, September 23, 2014 12:46 PM
  • Hi UmarAzhar,

    The Excel Object model doesn't support to import system.data.DataTable into Worksheet directly. However, as a workaround, we can use extend object to ahcieve the goal.

    For example, we can create a ListObject and bind the data to it. Here is a sample for your reference:

    System.Data.DataTable table = new System.Data.DataTable("Employees");
    
    table.Columns.Add("FirstName", typeof(string));
    table.Columns.Add("LastName", typeof(string));
    table.Columns.Add("Title", typeof(string));
    
    table.Rows.Add("Nancy", "Anderson", "Sales Representative");
    table.Rows.Add("Robert", "Brown", "Sales Representative");
    
    list1.AutoSetDataBoundColumnHeaders = true;
    list1.SetDataBinding(table, null, "LastName", "FirstName");
    

    You can get more detail from link below:
    How to: Fill ListObject Controls with Data

    Also here are some useful links for you learing ListObject control:

    How to: Add ListObject Controls to Worksheets

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, September 24, 2014 6:41 AM
    Moderator
  • i hav tried many time bt data table is not transferred in excel directly without looping

    Monday, October 13, 2014 10:11 AM
  • Hi UmarAzhar,

    Did you follow the code sample above? If it is not working would you mind sharing more detail information with us?

    regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 14, 2014 2:39 AM
    Moderator
  • hi,

    I want to insert data Table  in excel worksheet in one shot i.e  DataTable=worksheet

    till now i have seen all code samples that do this by iterating excel sheet cells one by one.

    Wednesday, December 24, 2014 5:26 AM
  • Hi UmarAzhar,

    >>till now i have seen all code samples that do this by iterating excel sheet cells one by one.<<

    No, the sample provied above is binding the data table to an extend object to export the data. And here is the link for the detail:
    How to: Fill ListObject Controls with Data

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, December 25, 2014 7:39 AM
    Moderator
  • No, the sample provied above is binding the data table to an extend object to export the data. And here is the link for the detail:
    How to: Fill ListObject Controls with Data

    sadly, the video link on that page does not work.

    For a related video demonstration, see How Do I: Create a List in Excel that is Connected to a SharePoint List?.

    Thursday, December 25, 2014 3:47 PM
  • Hi Steve Richter,

    No, the sample provied above is binding the data table to an extend object to export the data. And here is the link for the detail:
    How to: Fill ListObject Controls with Data

    sadly, the video link on that page does not work.

    For a related video demonstration, see How Do I: Create a List in Excel that is Connected to a SharePoint List?.

    Thanks for the feedback about the MSDN document. If there is any mistake or link broken in the document, you can submit the feedback from the bottom page of the document and click the button like figure below:

    And if you want to a compete workable code sample, here is the link that you can submit the request:
    Developer code samples

    Also if you have any other question about Office developing, please feel free to reopen a new thread. It would involve more communities and you will get more effective response.

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, December 26, 2014 3:28 AM
    Moderator