Extracting Data only - DataTable

Posted by: mth on 18 October 2020, 5:21 am EST

    • Post Options:
    • Link

    Posted 18 October 2020, 5:21 am EST

    I’m trying to extract the data in a Excel file in a format that I can easily query.

    Is there a simple way to do this?

    I’m thinking something along the line of a .net DataTable…

  • Posted 18 October 2020, 11:16 pm EST

    Hello Mathieu,

    You can apply the format to the Range of cell as demonstrated in the demo samples given below:

    https://www.grapecity.com/documents-api-excel/demos/numberformat

    >>I’m trying to extract the data in a Excel file in a format that I can easily query.

    Can you please specify the format in which you want to export the data?

    Regards,

    Prabhat Sharma.

  • Posted 19 October 2020, 2:59 am EST

    I’m not looking to format data.

    I’m looking to extract the content of an excel file and import it in a .net DataTable for example.

  • Posted 19 October 2020, 11:16 pm EST

    Hello Mathieu,

    There is no direct way to achieve this but as a workaround, you can iterate through each cell and store it in DataTable. Please find the attached sample implementing the same.

    Regards,

    Prabhat Sharma.

    GcExcelDemo.zip

  • Posted 5 November 2020, 8:20 am EST

    Hi Prabhat,

    Is there a way to get the numbers of rows from the worksheet?

    I’ve tried using:

    var count = worksheet.Rows.Count;
    

    But I’m getting 1048576 rows for a file with only 7 rows who have some values.

  • Posted 5 November 2020, 4:06 pm EST

    Hello Mathieu,

    You can use the code snippet to get the number of rows that have been used in the excel file:

    var count = worksheet.UsedRange.RowCount;
    
    

    If you need any other help, please let us know.

    Regards,

    Prabhat Sharma,

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels