private IEnumerable <Cell> GetCells(XMLNodeList rowElement, SharedStrings sharedStrings) { foreach (XMLNode cellElement in rowElement) { Cell cell = new Cell(cellElement, sharedStrings); if (cell.Value != null) { yield return(cell); } } }
/// <summary> /// Create a new Cell /// </summary> /// <param name="cellElement">Cell</param> /// <param name="sharedStrings">The collection of shared strings used by this document</param> public Cell(XMLNode cellElement, SharedStrings sharedStrings) { bool isTextRow = cellElement.GetValue("@t") == "s"; string columnName = cellElement.GetValue("@r"); this.ColumnNumber = GetExcelColumnNumber(columnName); if (isTextRow) { string textValue = cellElement.GetValue("v>0>_text"); this.Value = sharedStrings.GetString(textValue); } else { this.Value = cellElement.GetValue("_text"); } }
public Row(XMLNode rowElement, SharedStrings sharedStrings) { try { this.RowNumber = int.Parse(rowElement.GetValue("@r")); } catch (Exception ex) { throw new Exception("Row Number not found", ex); } XMLNodeList cellList = rowElement.GetNodeList("c"); if (cellList != null && cellList.Count > 0) { this.Cells = GetCells(rowElement.GetNodeList("c"), sharedStrings); } }