Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenXML linq query
    primarykey
    data
    text
    <p>I'm using OpenXML to open a spreadsheet and loop through the rows of a spreadsheet. I have a linq query that returns all cells within a row. The linq query was ripped straight from a demo on the MSDN. </p> <pre><code>IEnumerable&lt;String&gt; textValues = from cell in row.Descendants&lt;Cell&gt;() where cell.CellValue != null select (cell.DataType != null &amp;&amp; cell.DataType.HasValue &amp;&amp; cell.DataType == CellValues.SharedString ? sharedString.ChildElements[int.Parse(cell.CellValue.InnerText)].InnerText : cell.CellValue.InnerText); </code></pre> <p>The linq query is great at returning all cells that have a value, <strong>but it doesn't return cells that don't have a value</strong>. This in turn makes it impossible to tell which cell is which. Let me explain a little more. Say for instance we have three columns in our spreadsheet: Name, SSN, and Address. The way this linq query works is it only returns those cells that have a value for a given row. So if there is a row of data that has "John", "", "173 Sycamore" then the linq query only returns "John" and "173 Sycamore" in the enumeration, which in turn makes it impossible for me to know if "173 Sycamore" is the SSN or the Address field. </p> <p>Let me reiterate here: <strong>what I need is for all cells to be returned, and not just cells that contain a value</strong>.</p> <p>I've tried to monkey the linq query in every way that I could think of, but I had no luck whatsoever (ie - removing the where clause isn't the trick). Any help would be appreciated. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload