Reading records from Excel PivotCache
        Posted  
        
            by hcpremium
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by hcpremium
        
        
        
        Published on 2010-06-12T18:39:26Z
        Indexed on 
            2010/06/12
            18:42 UTC
        
        
        Read the original article
        Hit count: 322
        
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...
© Stack Overflow or respective owner