Пример #1
0
        internal static NpoiExcelCellValueHolder CreateFrom(CellValue cellValue)
        {
            cellValue.ThrowIfNull(nameof(cellValue));

            return(cellValue.CellType switch
            {
                CellType.String => new NpoiExcelCellValueHolder(cellValue.StringValue, isFormula: false),

                CellType.Numeric => new NpoiExcelCellValueHolder(cellValue.NumberValue),

                CellType.Boolean => new NpoiExcelCellValueHolder(cellValue.BooleanValue),

                CellType.Error => new NpoiExcelCellValueHolder(cellValue.ErrorValue),

                CellType.Formula => new NpoiExcelCellValueHolder(cellValue.StringValue, isFormula: true),

                _ => throw new ArgumentOutOfRangeException(
                    nameof(cellValue), cellValue.CellType,
                    $"Unknown cell type: '{cellValue.CellType.ToString()}'."
                    )
            });