Пример #1
0
        private string ConvertCellToString(SLCell cell, List <SLRstType> sharedStrings)
        {
            // Check if it is a number
            if (cell != null &&
                cell.DataType == CellValues.String &&
                cell.CellText != null)
            {
                return(cell.CellText.ToUpper());
            }
            else if (cell != null &&
                     cell.DataType == CellValues.SharedString)
            {
                return(sharedStrings[(int)cell.NumericValue].GetText().ToUpper());
            }
            else if (cell != null &&
                     cell.DataType == CellValues.Number)
            {
                return(cell.NumericValue.ToString().ToUpper());
            }

            throw new ArgumentException(
                      "The given cell is not able to be converted to a String.",
                      "SLCell cell",
                      new Exception(
                          $"Given Cell: {cell.ToString()}"));
        }
Пример #2
0
        private double ConvertCellToDouble(SLCell cell)
        {
            // Check if it is a number
            if (cell != null &&
                cell.DataType == CellValues.Number &&
                cell.CellText == null)
            {
                return(cell.NumericValue);
            }

            throw new ArgumentException(
                      "The given cell is not able to be converted to a Double.",
                      "SLCell cell",
                      new Exception(
                          $"Given Cell: {cell.ToString()}"));
        }