Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }