Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

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

50%
+0 −0
Q&A Which .NET project can programmatically validate a cell's value out of the box based on Excel data validation constraints?

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...

posted 1y ago by toraritte‭  ·  edited 1y ago by toraritte‭

Answer
#3: Post edited by user avatar toraritte‭ · 2023-11-22T20:16:24Z (about 1 year ago)
  • 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 by user avatar toraritte‭ · 2023-11-22T13:51:43Z (about 1 year ago)
  • 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 by user avatar toraritte‭ · 2023-11-20T20:10:20Z (about 1 year ago)
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--