Thursday, 17 January 2013

VB.NET - Excel - Pivot table - how to fix error Type Mismatch

Replace
Dim xlRange As Excel.Range = CType(osheet, Excel.Worksheet).Range("C2:AE70000")
Dim ptCache As Excel.PivotCache = obook.PivotCaches.Add(XlPivotTableSourceType.xlDatabase, xlRange)

With
              Dim ptCache As Excel.PivotCache = obook.PivotCaches.Add(SourceType:=Excel.XlPivotTableSourceType.xlDatabase, SourceData:="Emb!C2:AE70000")

1 comment: