Read data from Excel 2010 using Open XML SDK 2.0 RRS feed

  • Question


    Hi Everyone,

    I am trying to read data from an excel file (2010) using LINQ. I followed the exact same steps as posted in this article

    Now, The problem I have is that my data is denormalized it is not stored in different sheets but in the same sheet as shown below. Each entity is separated by an empty column and some columns might not contain data.

    Name City State   Number Date Customer Amount Status
    XYZ City1 State1   1 10-12-2010 X 12.22 Open
    Name2 City2 State2   3 10-12-2010 Customer 12.345 Status
            123 10-12-2010 C232 123.34 Closed
            34 10-13-2010 C12 12.345 Open

    When I try using the approach outlined in the above post the code fragment (below) returns me only 8 columns for each of the rows 2-3 (as first row is the Header columns) and from there on it returns me 5 columns for rows 4-5. It is actually ignoring empty columns in the list. But I need those empty columns so as to identify different entities.

    IEnumerable<Row> dataRows =
       from row in worksheet.Descendants<Row>()
       where row.RowIndex > 1
       select row;


    Is there any way for me get all the columns without the empty columns being ignored ?


    Thank You,


    Wednesday, October 27, 2010 5:26 PM