Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Here's a list of popular Excel .NET projects that don't have this functionality: Has built-in cell validation? Open XML SDK no* NPOI no* EPPlus no? (see section 3. be...
Answer
#3: Post edited
Don't have an answer (yet), but here's a list of popular Excel .NET projects that **don't** have this functionality:- | | Has built-in cell validation? |
- |--------------|-------------------------------|
- | Open XML SDK | no<sup>*</sup> |
- | NPOI | no<sup>*</sup> |
- | EPPlus | no? (see section 3. below) |
- | ClosedXML | no<sup>*</sup> |
- <sup>\* Non-authoritative answer (i.e., post author couldn't find proof for support)</sup>
- ### 1. Open XML SDK for Microsoft Office
- Can only be used to get or set data validation rules. (See [`DataValidation` class](https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.datavalidation).)
- ### 2. NPOI
- Couldn't find anything except [`NPOI.SS.Formula.DataValidationEvaluator`][3] (see NOTE below).
- > **NOTE**\
- > NPOI was inspired Apache POI, and [`NPOI.SS.Formula.DataValidationEvaluator`][3] seems to mirror Apache POI's [`DataValidationEvaluator`][1] class. However, as of 11/20/2023, NPOI's version only has one method, `IsType` (whose specs are the same as [`isType`][4]'s though).
- >
- > Also, Apache POI[`DataValidationEvaluator`][1] class' [`isValidCell`][2] method:
- >
- > > `public boolean isValidCell(CellReference cellRef)`
- > >
- > > Use the validation returned by `getValidationForCell(CellReference)` if you want the error display details. This is the validation checked by this method, which attempts to replicate Excel's data validation rules.
- > >
- > > Note that to properly apply some validations, care must be taken to offset the base validation formula by the relative position of the current cell, or the wrong value is checked.
- > >
- > > **Parameters**:\
- > > `cellRef` - The reference of the cell to evaluate
- > >
- > > **Returns**:\
- > > `true` if the cell has no validation or the cell value passes the defined validation, `false` if it fails
- > **QUESTION**\
- > Apache POI's [`XSSFDataValidationConstraint` class](https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.html) also has a [`validate`][5] method, but can't decide based on the docs whether it is germane to this discussion.
- ### 3. EPPlus
- Found the [`InternalValidationEnabled`](https://epplussoftware.com/docs/5.2/api/OfficeOpenXml.DataValidation.ExcelDataValidationCollection.html#OfficeOpenXml_DataValidation_ExcelDataValidationCollection_InternalValidationEnabled) property (see below), but I think it is only meant to check the consistency of the data validation rules themselves, and not if the cells conform to them.
- > ### class `ExcelDataValidationCollection`
- > `InternalValidationEnabled`\
- > Epplus validates that all data validations are consistent and valid when they are added and when a workbook is saved. Since this takes some resources, it can be disabled for improve performance.
- >
- > **Declaration**\
- > `public bool InternalValidationEnabled { get; set; }`
- ### 4. ClosedXML
- Based on the sources below, it does not have built-in cell validation.
- + [Data Validation · ClosedXML/ClosedXML Wiki](https://github.com/ClosedXML/ClosedXML/wiki/Data-Validation)
- + [GitHub code search results for "validat"](https://github.com/search?q=repo%3AClosedXML%2FClosedXML%20validat&type=code)
- + [Cell — ClosedXML 0.102.0 documentation](https://docs.closedxml.io/en/latest/api/cell.html)
- [1]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html
- [2]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html#isValidCell-org.apache.poi.ss.util.CellReference-
- [3]: https://github.com/nissl-lab/npoi/blob/master/main/SS/Formula/DataValidationEvaluator.cs
- [4]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html#isType-org.apache.poi.ss.usermodel.Cell-org.apache.poi.ss.usermodel.CellType-
- [5]: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.html#validate--
- Here's a list of popular Excel .NET projects that **don't** have this functionality:
- | | Has built-in cell validation? |
- |--------------|-------------------------------|
- | Open XML SDK | no<sup>*</sup> |
- | NPOI | no<sup>*</sup> |
- | EPPlus | no? (see section 3. below) |
- | ClosedXML | no<sup>*</sup> |
- <sup>\* Non-authoritative answer (i.e., post author couldn't find proof for support)</sup>
- ### 1. Open XML SDK for Microsoft Office
- Can only be used to get or set data validation rules. (See [`DataValidation` class](https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.datavalidation).)
- ### 2. NPOI
- Couldn't find anything except [`NPOI.SS.Formula.DataValidationEvaluator`][3] (see NOTE below).
- > **NOTE**\
- > NPOI was inspired Apache POI, and [`NPOI.SS.Formula.DataValidationEvaluator`][3] seems to mirror Apache POI's [`DataValidationEvaluator`][1] class. However, as of 11/20/2023, NPOI's version only has one method, `IsType` (whose specs are the same as [`isType`][4]'s though).
- >
- > Also, Apache POI[`DataValidationEvaluator`][1] class' [`isValidCell`][2] method:
- >
- > > `public boolean isValidCell(CellReference cellRef)`
- > >
- > > Use the validation returned by `getValidationForCell(CellReference)` if you want the error display details. This is the validation checked by this method, which attempts to replicate Excel's data validation rules.
- > >
- > > Note that to properly apply some validations, care must be taken to offset the base validation formula by the relative position of the current cell, or the wrong value is checked.
- > >
- > > **Parameters**:\
- > > `cellRef` - The reference of the cell to evaluate
- > >
- > > **Returns**:\
- > > `true` if the cell has no validation or the cell value passes the defined validation, `false` if it fails
- > **QUESTION**\
- > Apache POI's [`XSSFDataValidationConstraint` class](https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.html) also has a [`validate`][5] method, but can't decide based on the docs whether it is germane to this discussion.
- ### 3. EPPlus
- Found the [`InternalValidationEnabled`](https://epplussoftware.com/docs/5.2/api/OfficeOpenXml.DataValidation.ExcelDataValidationCollection.html#OfficeOpenXml_DataValidation_ExcelDataValidationCollection_InternalValidationEnabled) property (see below), but I think it is only meant to check the consistency of the data validation rules themselves, and not if the cells conform to them.
- > ### class `ExcelDataValidationCollection`
- > `InternalValidationEnabled`\
- > Epplus validates that all data validations are consistent and valid when they are added and when a workbook is saved. Since this takes some resources, it can be disabled for improve performance.
- >
- > **Declaration**\
- > `public bool InternalValidationEnabled { get; set; }`
- ### 4. ClosedXML
- Based on the sources below, it does not have built-in cell validation.
- + [Data Validation · ClosedXML/ClosedXML Wiki](https://github.com/ClosedXML/ClosedXML/wiki/Data-Validation)
- + [GitHub code search results for "validat"](https://github.com/search?q=repo%3AClosedXML%2FClosedXML%20validat&type=code)
- + [Cell — ClosedXML 0.102.0 documentation](https://docs.closedxml.io/en/latest/api/cell.html)
- [1]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html
- [2]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html#isValidCell-org.apache.poi.ss.util.CellReference-
- [3]: https://github.com/nissl-lab/npoi/blob/master/main/SS/Formula/DataValidationEvaluator.cs
- [4]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html#isType-org.apache.poi.ss.usermodel.Cell-org.apache.poi.ss.usermodel.CellType-
- [5]: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.html#validate--
#2: Post edited
TL;DR- | | Has built-in cell validation? |
- |--------------|-------------------------------|
- | Open XML SDK | no<sup>*</sup> |
- | NPOI | no<sup>*</sup> |
- | EPPlus | no? (see section 3. below) |
- | ClosedXML | no<sup>*</sup> |
- <sup>\* Non-authoritative answer (i.e., post author couldn't find proof for support)</sup>
- ### 1. Open XML SDK for Microsoft Office
- Can only be used to get or set data validation rules. (See [`DataValidation` class](https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.datavalidation).)
- ### 2. NPOI
- Couldn't find anything except [`NPOI.SS.Formula.DataValidationEvaluator`][3] (see NOTE below).
- > **NOTE**\
- > NPOI was inspired Apache POI, and [`NPOI.SS.Formula.DataValidationEvaluator`][3] seems to mirror Apache POI's [`DataValidationEvaluator`][1] class. However, as of 11/20/2023, NPOI's version only has one method, `IsType` (whose specs are the same as [`isType`][4]'s though).
- >
- > Also, Apache POI[`DataValidationEvaluator`][1] class' [`isValidCell`][2] method:
- >
- > > `public boolean isValidCell(CellReference cellRef)`
- > >
- > > Use the validation returned by `getValidationForCell(CellReference)` if you want the error display details. This is the validation checked by this method, which attempts to replicate Excel's data validation rules.
- > >
- > > Note that to properly apply some validations, care must be taken to offset the base validation formula by the relative position of the current cell, or the wrong value is checked.
- > >
- > > **Parameters**:\
- > > `cellRef` - The reference of the cell to evaluate
- > >
- > > **Returns**:\
- > > `true` if the cell has no validation or the cell value passes the defined validation, `false` if it fails
- > **QUESTION**\
- > Apache POI's [`XSSFDataValidationConstraint` class](https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.html) also has a [`validate`][5] method, but can't decide based on the docs whether it is germane to this discussion.
- ### 3. EPPlus
- Found the [`InternalValidationEnabled`](https://epplussoftware.com/docs/5.2/api/OfficeOpenXml.DataValidation.ExcelDataValidationCollection.html#OfficeOpenXml_DataValidation_ExcelDataValidationCollection_InternalValidationEnabled) property (see below), but I think it is only meant to check the consistency of the data validation rules themselves, and not if the cells conform to them.
- > ### class `ExcelDataValidationCollection`
- > `InternalValidationEnabled`\
- > Epplus validates that all data validations are consistent and valid when they are added and when a workbook is saved. Since this takes some resources, it can be disabled for improve performance.
- >
- > **Declaration**\
- > `public bool InternalValidationEnabled { get; set; }`
- ### 4. ClosedXML
- Based on the sources below, it does not have built-in cell validation.
- + [Data Validation · ClosedXML/ClosedXML Wiki](https://github.com/ClosedXML/ClosedXML/wiki/Data-Validation)
- + [GitHub code search results for "validat"](https://github.com/search?q=repo%3AClosedXML%2FClosedXML%20validat&type=code)
- + [Cell — ClosedXML 0.102.0 documentation](https://docs.closedxml.io/en/latest/api/cell.html)
- [1]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html
- [2]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html#isValidCell-org.apache.poi.ss.util.CellReference-
- [3]: https://github.com/nissl-lab/npoi/blob/master/main/SS/Formula/DataValidationEvaluator.cs
- [4]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html#isType-org.apache.poi.ss.usermodel.Cell-org.apache.poi.ss.usermodel.CellType-
- [5]: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.html#validate--
- Don't have an answer (yet), but here's a list of popular Excel .NET projects that **don't** have this functionality:
- | | Has built-in cell validation? |
- |--------------|-------------------------------|
- | Open XML SDK | no<sup>*</sup> |
- | NPOI | no<sup>*</sup> |
- | EPPlus | no? (see section 3. below) |
- | ClosedXML | no<sup>*</sup> |
- <sup>\* Non-authoritative answer (i.e., post author couldn't find proof for support)</sup>
- ### 1. Open XML SDK for Microsoft Office
- Can only be used to get or set data validation rules. (See [`DataValidation` class](https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.datavalidation).)
- ### 2. NPOI
- Couldn't find anything except [`NPOI.SS.Formula.DataValidationEvaluator`][3] (see NOTE below).
- > **NOTE**\
- > NPOI was inspired Apache POI, and [`NPOI.SS.Formula.DataValidationEvaluator`][3] seems to mirror Apache POI's [`DataValidationEvaluator`][1] class. However, as of 11/20/2023, NPOI's version only has one method, `IsType` (whose specs are the same as [`isType`][4]'s though).
- >
- > Also, Apache POI[`DataValidationEvaluator`][1] class' [`isValidCell`][2] method:
- >
- > > `public boolean isValidCell(CellReference cellRef)`
- > >
- > > Use the validation returned by `getValidationForCell(CellReference)` if you want the error display details. This is the validation checked by this method, which attempts to replicate Excel's data validation rules.
- > >
- > > Note that to properly apply some validations, care must be taken to offset the base validation formula by the relative position of the current cell, or the wrong value is checked.
- > >
- > > **Parameters**:\
- > > `cellRef` - The reference of the cell to evaluate
- > >
- > > **Returns**:\
- > > `true` if the cell has no validation or the cell value passes the defined validation, `false` if it fails
- > **QUESTION**\
- > Apache POI's [`XSSFDataValidationConstraint` class](https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.html) also has a [`validate`][5] method, but can't decide based on the docs whether it is germane to this discussion.
- ### 3. EPPlus
- Found the [`InternalValidationEnabled`](https://epplussoftware.com/docs/5.2/api/OfficeOpenXml.DataValidation.ExcelDataValidationCollection.html#OfficeOpenXml_DataValidation_ExcelDataValidationCollection_InternalValidationEnabled) property (see below), but I think it is only meant to check the consistency of the data validation rules themselves, and not if the cells conform to them.
- > ### class `ExcelDataValidationCollection`
- > `InternalValidationEnabled`\
- > Epplus validates that all data validations are consistent and valid when they are added and when a workbook is saved. Since this takes some resources, it can be disabled for improve performance.
- >
- > **Declaration**\
- > `public bool InternalValidationEnabled { get; set; }`
- ### 4. ClosedXML
- Based on the sources below, it does not have built-in cell validation.
- + [Data Validation · ClosedXML/ClosedXML Wiki](https://github.com/ClosedXML/ClosedXML/wiki/Data-Validation)
- + [GitHub code search results for "validat"](https://github.com/search?q=repo%3AClosedXML%2FClosedXML%20validat&type=code)
- + [Cell — ClosedXML 0.102.0 documentation](https://docs.closedxml.io/en/latest/api/cell.html)
- [1]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html
- [2]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html#isValidCell-org.apache.poi.ss.util.CellReference-
- [3]: https://github.com/nissl-lab/npoi/blob/master/main/SS/Formula/DataValidationEvaluator.cs
- [4]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html#isType-org.apache.poi.ss.usermodel.Cell-org.apache.poi.ss.usermodel.CellType-
- [5]: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.html#validate--
#1: Initial revision
TL;DR | | Has built-in cell validation? | |--------------|-------------------------------| | Open XML SDK | no<sup>*</sup> | | NPOI | no<sup>*</sup> | | EPPlus | no? (see section 3. below) | | ClosedXML | no<sup>*</sup> | <sup>\* Non-authoritative answer (i.e., post author couldn't find proof for support)</sup> ### 1. Open XML SDK for Microsoft Office Can only be used to get or set data validation rules. (See [`DataValidation` class](https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.datavalidation).) ### 2. NPOI Couldn't find anything except [`NPOI.SS.Formula.DataValidationEvaluator`][3] (see NOTE below). > **NOTE**\ > NPOI was inspired Apache POI, and [`NPOI.SS.Formula.DataValidationEvaluator`][3] seems to mirror Apache POI's [`DataValidationEvaluator`][1] class. However, as of 11/20/2023, NPOI's version only has one method, `IsType` (whose specs are the same as [`isType`][4]'s though). > > Also, Apache POI[`DataValidationEvaluator`][1] class' [`isValidCell`][2] method: > > > `public boolean isValidCell(CellReference cellRef)` > > > > Use the validation returned by `getValidationForCell(CellReference)` if you want the error display details. This is the validation checked by this method, which attempts to replicate Excel's data validation rules. > > > > Note that to properly apply some validations, care must be taken to offset the base validation formula by the relative position of the current cell, or the wrong value is checked. > > > > **Parameters**:\ > > `cellRef` - The reference of the cell to evaluate > > > > **Returns**:\ > > `true` if the cell has no validation or the cell value passes the defined validation, `false` if it fails > **QUESTION**\ > Apache POI's [`XSSFDataValidationConstraint` class](https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.html) also has a [`validate`][5] method, but can't decide based on the docs whether it is germane to this discussion. ### 3. EPPlus Found the [`InternalValidationEnabled`](https://epplussoftware.com/docs/5.2/api/OfficeOpenXml.DataValidation.ExcelDataValidationCollection.html#OfficeOpenXml_DataValidation_ExcelDataValidationCollection_InternalValidationEnabled) property (see below), but I think it is only meant to check the consistency of the data validation rules themselves, and not if the cells conform to them. > ### class `ExcelDataValidationCollection` > `InternalValidationEnabled`\ > Epplus validates that all data validations are consistent and valid when they are added and when a workbook is saved. Since this takes some resources, it can be disabled for improve performance. > > **Declaration**\ > `public bool InternalValidationEnabled { get; set; }` ### 4. ClosedXML Based on the sources below, it does not have built-in cell validation. + [Data Validation · ClosedXML/ClosedXML Wiki](https://github.com/ClosedXML/ClosedXML/wiki/Data-Validation) + [GitHub code search results for "validat"](https://github.com/search?q=repo%3AClosedXML%2FClosedXML%20validat&type=code) + [Cell — ClosedXML 0.102.0 documentation](https://docs.closedxml.io/en/latest/api/cell.html) [1]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html [2]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html#isValidCell-org.apache.poi.ss.util.CellReference- [3]: https://github.com/nissl-lab/npoi/blob/master/main/SS/Formula/DataValidationEvaluator.cs [4]: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/formula/DataValidationEvaluator.html#isType-org.apache.poi.ss.usermodel.Cell-org.apache.poi.ss.usermodel.CellType- [5]: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.html#validate--