none
How to read tables in Excel Worksheet witc C# and XML Pin RRS feed

  • Question

  • Hi guys,
     
    What I'm trying to do is to programmatically open a Excel Worksheet and then within a given range read and analyse all of the tables. 
     
    I already know how to open the file and find used range per sheet. But how do I get all the tables from it?
     
    Someone an idea how make this possible? I would be really greatfull.
    • Edited by SuSNL Thursday, October 16, 2014 1:15 PM
    Thursday, October 16, 2014 1:15 PM

All replies

  • Hi SuSNL,

    Thanks for posting in MSDN forum.

    From the description, you were opening the workbook and read the data from worksheets. Did you use the Excel Object model to read data? And does the tables mean like figure below?

    If I understood correctly, the tables corresponds ListObject in Excel Object model. We can use the ListObjects property of the Worksheetobject to return a ListObjects collection. To get all ListObjects, we can loop through the all worksheets.

    Hope it is helpful.

    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.

    Friday, October 17, 2014 6:30 AM
    Moderator
  • If you mean Excel Interop- no I'm not using it. I'm working with really large Excel files and Excel Interop doesn't quite seem to operate on them properly. I'm trying to do as much as possilbe with OpenXML but is not as Object oriented as Excel Interop, and that makes is much harder :S
    Friday, October 17, 2014 7:18 AM
  • Hi SuSNL.

    >>I'm trying to do as much as possilbe with OpenXML but is not as Object oriented as Excel Interop, and that makes is much harder :S<<

    Yes, there are differernt. As far as I know, we can read the content of range cell by cell using Open XML. If the data in the spreadsheet is structed, we can also use ADO.Net to read the data from it.

    Here is an article for your reference:
    Using ADO.NET to work with Excel files

    Hope it is helpful.
    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.

    Tuesday, October 21, 2014 6:55 AM
    Moderator