Reading records from Excel PivotCache
- by hcpremium
I have an Excel workbook which contains a PivotCache I would like to use as a data source.
var file = @"Foo.xls";
var excel = new Excel.Application();
var workbook = excel.Workbooks.Open(file);
Excel.PivotCache cache = null;
foreach (Excel.PivotCache pivotCache in workbook.PivotCaches())
{
if (...)
{
cache = pivotCache;
}
}
var records = cache.Recordset;
The last command throws an exception (Exception from HRESULT: 0x800A03EC).
How can I access the PivotCache? I tried it thru Ole DB first, but no success...