Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

Closed Unassigned: Error doing data validation from another sheet [9498]

$
0
0
When using closedxml to add data validation to a file, all validations are written in the <x:dataValidations> element. However, this is not how excel saves data validation from other sheets.

Here's how closed xml saves it:

```
<x:dataValidations count="3">
<x:dataValidation type="list" errorStyle="warning" operator="between" allowBlank="0" showDropDown="0" showInputMessage="1" showErrorMessage="1" errorTitle="" error="" promptTitle="" prompt="" sqref="B6:B6">
<x:formula1>"Foo,Bar,FooBar"</x:formula1>
<x:formula2></x:formula2>
</x:dataValidation>
<x:dataValidation type="list" errorStyle="warning" operator="between" allowBlank="0" showDropDown="0" showInputMessage="1" showErrorMessage="1" errorTitle="" error="" promptTitle="" prompt="" sqref="C6:C6">
<x:formula1>'HiddenDataValSheet'!$A$1:$A$1000</x:formula1>
<x:formula2></x:formula2>
</x:dataValidation>
<x:dataValidation type="list" errorStyle="warning" operator="between" allowBlank="0" showDropDown="0" showInputMessage="1" showErrorMessage="1" errorTitle="" error="" promptTitle="" prompt="" sqref="D6:D6">
<x:formula1>'HiddenDataValSheet'!$B$1:$B$1000</x:formula1>
<x:formula2></x:formula2>
</x:dataValidation>
</x:dataValidations>

```

And here's how excel saves it:

```
<extLst>
<ext uri="{CCE6A557-97BC-4b89-ADB6-D9C93CAAB3DF}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main">
<x14:dataValidations count="2" xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
<x14:dataValidation type="list" errorStyle="warning" showInputMessage="1" showErrorMessage="1">
<x14:formula1>
<xm:f>HiddenDataValSheet!$A$1:$A$1000</xm:f>
</x14:formula1>
<xm:sqref>C6</xm:sqref>
</x14:dataValidation>
<x14:dataValidation type="list" errorStyle="warning" showInputMessage="1" showErrorMessage="1">
<x14:formula1>
<xm:f>HiddenDataValSheet!$B$1:$B$1000</xm:f>
</x14:formula1>
<xm:sqref>D6</xm:sqref>
</x14:dataValidation>
</x14:dataValidations>
</ext>

```

I'll need to modify the closed xml code to be able to read the data validations from the <extLst> element and treat them like normal data validations.

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>