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

Commented Issue: Workbook cannot be opened if it contains a table that is filtered by a date. [8581]

$
0
0
The following code results in an InvalidCastException when the Workbook contains a table where a column is filtered by the date. At example workbook is attached.

```
new XLWorkbook(@"C:\Scratch\DateFilter example.xlsx")
```

The full details of the exception are:
```
Unable to cast object of type 'DocumentFormat.OpenXml.Spreadsheet.DateGroupItem' to type 'DocumentFormat.OpenXml.Spreadsheet.Filter'.
at ClosedXML.Excel.XLWorkbook.LoadAutoFilterColumns(AutoFilter af, XLAutoFilter autoFilter)
at ClosedXML.Excel.XLWorkbook.LoadSpreadsheetDocument(SpreadsheetDocument dSpreadsheet)
at ClosedXML.Excel.XLWorkbook.LoadSheets(String fileName)
at ClosedXML.Excel.XLWorkbook..ctor(String file)
```
Comments: ** Comment from web user: Ged325 **

I added this to XLWorkbook_Load.cs at line ~1200

Boolean isText = false;
[b] foreach (Object f in filterColumn.Filters)
{

if (f.GetType().FullName == "DocumentFormat.OpenXml.Spreadsheet.Filter")
{
[/b]
foreach (Filter filter in filterColumn.Filters)
{


Viewing all articles
Browse latest Browse all 1877

Trending Articles



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