I am usung a file that has a datavalidation element. When I load that file and remove the existing DataValidation item then the root item "DataValidations" will be removed. That is ok.
But when I add a new DataValidation item then the internal function "ExcelDataValidation.cs" -> "EnsureRootElementExists()" will not create the required "DataValidations" item.
I am using the following workaround:
```
private void EnsureRootElementExists()
{
var node = _worksheet.WorksheetXml.SelectSingleNode(DataValidationPath, _worksheet.NameSpaceManager);
if (node == null)
{
TopNode = _worksheet.WorksheetXml.DocumentElement; // This line fixes the problem
CreateNode(DataValidationPath.TrimStart('/'));
}
}
```
The problem is that "CreateNode" requires "TopNode" to be the sheet. TopNode is overwritten by "GetRootNode".
Comments: The correct file is "ExcelDataValidationCollection.cs" -> "private void EnsureRootElementExists()"
But when I add a new DataValidation item then the internal function "ExcelDataValidation.cs" -> "EnsureRootElementExists()" will not create the required "DataValidations" item.
I am using the following workaround:
```
private void EnsureRootElementExists()
{
var node = _worksheet.WorksheetXml.SelectSingleNode(DataValidationPath, _worksheet.NameSpaceManager);
if (node == null)
{
TopNode = _worksheet.WorksheetXml.DocumentElement; // This line fixes the problem
CreateNode(DataValidationPath.TrimStart('/'));
}
}
```
The problem is that "CreateNode" requires "TopNode" to be the sheet. TopNode is overwritten by "GetRootNode".
Comments: The correct file is "ExcelDataValidationCollection.cs" -> "private void EnsureRootElementExists()"