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: rhysparry **

Thanks @Ged325.

I've attached my patch which works in a similar way to yours except using the OfType<T>() extension method to do the necessary filter filtering by type. Like you I only need the data which seems to be workable with the solution and so far doesn't seem to make things any worse than they already are.


Viewing all articles
Browse latest Browse all 1877

Trending Articles



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