Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I'm developing a Microsoft.Office.Interopt.Excel app in asp.net/C#/.net 3.5, using VS 2008.

I'm trying to refresh a pivot table but the
The following statement won't compile .
C#
wkSheet.PivotTables("PivotTable1").PivotCache.Refresh;


I keep getting the following 2 erros. Can someone please help!

1.   Only assignment, call, increment, decrement, and new object expressions can be used as a statement	

2.   'object' does not contain a definition for 'PivotCache' and no extension method 'PivotCache' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Posted
Updated 7-Dec-11 5:28am
v2
Comments
Wonde Tadesse 7-Dec-11 11:48am    
Ms office with Asp.Net not recommended. Try 3rd party libraries, like Aspose.cells.
Member 7969139 7-Dec-11 12:00pm    
What problems do you know of?
Wonde Tadesse 7-Dec-11 12:26pm    
Please read this guide line. http://support.microsoft.com/kb/257757

1 solution

Both of those messages ar fairly clear, try something like:
C#
PivotTable pvtTable = (PivotTable)wkSheet.PivotTables("PivotTable1");
pvtTable.RefreshTable();
 
Share this answer
 
Comments
Member 7969139 7-Dec-11 13:11pm    
Thanks that fixed it. Just needed to add microsoft.office.interopt.excel in front of PivotTable

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900