Skip to content

Commit

Permalink
Pull request JanKallman#334 Make validation optional. New property In…
Browse files Browse the repository at this point in the history
…ternalValidationEnabled on ExcelDataValidationCollection
  • Loading branch information
swmal committed Dec 28, 2018
1 parent 57d5afc commit b7c82dd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions EPPlus/DataValidation/ExcelDataValidationCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ internal ExcelDataValidationCollection(ExcelWorksheet worksheet)
{
OnValidationCountChanged();
}

InternalValidationEnabled = true;
}

private void EnsureRootElementExists()
Expand Down Expand Up @@ -161,6 +163,8 @@ private void ValidateAddress(string address, IExcelDataValidation validatingVali
{
Require.Argument(address).IsNotNullOrEmpty("address");

if (!InternalValidationEnabled) return;

// ensure that the new address does not collide with an existing validation.
var newAddress = new ExcelAddress(address);
if (_validations.Count > 0)
Expand Down Expand Up @@ -190,6 +194,8 @@ private void ValidateAddress(string address)
/// </summary>
internal void ValidateAll()
{
if (!InternalValidationEnabled) return;

foreach (var validation in _validations)
{
validation.Validate();
Expand Down Expand Up @@ -344,6 +350,18 @@ public int Count
get { return _validations.Count; }
}


/// <summary>
/// Epplus validates that all data validations are consistend and valid
/// when they are added and when a workbook is saved. Since this takes some
/// resources, it can be disabled for improve performance.
/// </summary>
public bool InternalValidationEnabled
{
get;
set;
}

/// <summary>
/// Index operator, returns by 0-based index
/// </summary>
Expand Down

0 comments on commit b7c82dd

Please sign in to comment.