Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I have Open XML spreadsheet "uncollapse" cells in a spreadsheet?
    primarykey
    data
    text
    <p>I'm working with xslx Excel file on the server side in C#. In a spreadsheet, say there are 15 columns (cells) total. In the rows of cells, some values are missing. So the first row is my header will properly have the 15 cells. But my data rows, some cells might have empty values, so Open XML has a "jagged" set of cells values. Row 1 will have the full 15 cells, Row 2 might have 13 cells since two of the values are empty. What! How do I map this data properly? It basically shifts everything to the left and my cell values are wrong. What am I missing? It seems like they are being "collapsed" in Open XML terminology.</p> <pre><code>WorkbookPart workbookPart = spreadSheetDocument.WorkbookPart; IEnumerable&lt;Sheet&gt; sheets = spreadSheetDocument.WorkbookPart.Workbook.GetFirstChild&lt;Sheets&gt;().Elements&lt;Sheet&gt;(); string relationshipId = sheets.First().Id.Value; WorksheetPart worksheetPart = (WorksheetPart)spreadSheetDocument.WorkbookPart.GetPartById(relationshipId); Worksheet workSheet = worksheetPart.Worksheet; SheetData sheetData = workSheet.GetFirstChild&lt;SheetData&gt;(); IEnumerable&lt;Row&gt; rows = sheetData.Descendants&lt;Row&gt;(); </code></pre> <p>CLARIFICATION: Here's another way to ask this question. What if I want to take the contents on an Excel file and put it into a DataTable. I want all the columns of data to line up correctly. How could I accomplish this?</p> <p>This question is asked better than I here: <a href="https://stackoverflow.com/questions/3837981/reading-excel-open-xml-is-ignoring-blank-cells">reading Excel Open XML is ignoring blank cells</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    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