public string GetElement(object col, int row) { ExcelFileException.ThrowIfStringNull((string)col); if ((int)col < 0 | row < 0) { throw new ExcelFileException($"Столбцы могут быть только положительные."); } string res = null; switch (col.GetType().ToString()) { case "System.String": { if (IsExistColumn((string)col)) { res = data.Rows[row][(string)col].ToString(); } break; } case "System.Int32": { res = data.Rows[row][(int)col].ToString(); break; } default: throw new Exception($"Форма колонки не правильно задан."); } return(res); }
public bool IsExistColumn(string name) { int i = 0; ExcelFileException.ThrowIfStringNull(name); foreach (string colname in columns.Split(';')) { if (colname == name) { i++; } } return(i > 0 ? true : false); }
public bool IsExistSheet(string name) { int i = 0; ExcelFileException.ThrowIfStringNull(name); foreach (string sheet in sheetnames.Split(';')) { if (sheet == name) { i++; } } return(i > 0 ? true : false); }