SharedStringTablePart string_table_part = doc.WorkbookPart.SharedStringTablePart; List<string> string_table = new List<string>(); foreach (OpenXmlElement node in string_table_part.SharedStringTable.ChildElements) { string_table.Add(node.InnerText); }
if (cell.DataType == CellValues.SharedString) { text = string_table.ElementAt(Convert.ToInt32(cell.CellValue.InnerText)); } else { text = cell.CellValue.InnerText; }
staticvoidGetRowAndColumn(string cellReference, outint row, outint column) { row = 0; column = 0; string columnLetters = ""; // column index foreach (char c in cellReference) { if (char.IsLetter(c)) { columnLetters += c; } else { break; } } column = ColumnLettersToNumber(columnLetters); // row index int.TryParse(cellReference.Substring(columnLetters.Length), out row); }
staticintColumnLettersToNumber(string letters) { int result = 0; foreach (char c in letters) { result = result * 26 + (c - 'A' + 1); } return result; }