none
Unable to read value from an Excel cell RRS feed

  • Question

  • I am using SpreadSheetXML to read data from Excel cells. Here is my issue.

    i am reading cell "H17" in the worksheet. there is no data in that cell so i am expecting an empty string back. But if i look at the XML for that worksheet, there is no entry for cell H17.

    <c r="G17" s="160" t="s">
         <v>3</v>
    </c>
    <c r="I17" s="160" t="s">
        <v>4</v>
    </c>

    i have a routine which reads data from each cell of the row. so the code is -

    currentRow.Descendants<Cell>().ElementAtOrDefault(7).CellValue

    Here the currentRow is the 17th row and 7 is the H cell of that row. the value returned for me is 4 which is actually the value of cell "I17". how do i get the value of H17 as a null string especially when the value is not present in the sheet.xml.

    Thanks,

    Ullas

    Thursday, October 7, 2010 12:26 AM

Answers

  • Hi Ullas,

    Basically it contains only those cells which has a value in it. To achieve this, you can write a function which will check if the value is not there, return null.

    Thanks
    Ankush


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Ankush Microsoft Online Community Support
    • Marked as answer by Ankush_Bhatia Thursday, October 14, 2010 11:09 AM
    Thursday, October 14, 2010 11:09 AM