Skip to content

Commit

Permalink
Create a CellReference after checking the number of data validations …
Browse files Browse the repository at this point in the history
…in TryAddDataValidation
  • Loading branch information
sveinungf committed Feb 19, 2023
1 parent 01de7ae commit 0521234
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions SpreadCheetah/Spreadsheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,7 @@ public bool TryAddDataValidation(string reference, DataValidation validation)
{
ArgumentNullException.ThrowIfNull(validation);
ArgumentNullException.ThrowIfNull(reference);

var cellReference = CellReference.Create(reference, true, CellReferenceType.RelativeOrAbsolute);
return Worksheet.TryAddDataValidation(cellReference, validation);
return Worksheet.TryAddDataValidation(reference, validation);
}

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions SpreadCheetah/Worksheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,15 @@ public ValueTask AddRowAsync(ReadOnlyMemory<DataCell> cells, RowOptions options,
public ValueTask AddRowAsync(ReadOnlyMemory<StyledCell> cells, RowOptions options, int currentIndex, CancellationToken ct)
=> _styledCellWriter.AddRowAsync(cells, _nextRowIndex - 1, options, currentIndex, _stream, ct);

public bool TryAddDataValidation(CellReference reference, DataValidation validation)
public bool TryAddDataValidation(string reference, DataValidation validation)
{
_validations ??= new Dictionary<CellReference, DataValidation>();

if (_validations.Count >= SpreadsheetConstants.MaxNumberOfDataValidations)
return false;

_validations[reference] = validation;
var cellReference = CellReference.Create(reference, true, CellReferenceType.RelativeOrAbsolute);
_validations[cellReference] = validation;
return true;
}

Expand Down

0 comments on commit 0521234

Please sign in to comment.