excel
-
Hi, The c# code is populating a workbook template with the latest data which is run by the c# code... in the c# code there is workbook.RefreshAll(); At this stage, I expect to see the latest data inside the spreadsheet BUT the template shows the old data which was in the template before. To see the latest data, I have to go to the spreadsheet which was populated but I have to click on data, refresh data to see the latest figures. How can I solve this please? Thanks
-
Hi, The c# code is populating a workbook template with the latest data which is run by the c# code... in the c# code there is workbook.RefreshAll(); At this stage, I expect to see the latest data inside the spreadsheet BUT the template shows the old data which was in the template before. To see the latest data, I have to go to the spreadsheet which was populated but I have to click on data, refresh data to see the latest figures. How can I solve this please? Thanks
A useful tip for solving a problem such as this is to look at the code generated by the MS Office macro recorder. In your case go the spreadsheet, turn on the recorder, and perform the actions required to refresh the data. Examine the macro's BASIC source code to find out how it was done. It usually fairly simple to write the C# version but if you have any problems post the macro code here. Alan.
-
A useful tip for solving a problem such as this is to look at the code generated by the MS Office macro recorder. In your case go the spreadsheet, turn on the recorder, and perform the actions required to refresh the data. Examine the macro's BASIC source code to find out how it was done. It usually fairly simple to write the C# version but if you have any problems post the macro code here. Alan.
-
Alan's right... Even if you're not using macros for your actual project, try recording a macro that does what you need. Excel will automatically generate the code in VBA, and you can use that as a guide to figure out how to do it in C#.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Yes I understand that you are not writing a macro but in many cases macro code and office interop code are very similar. This means that the macro code for the update operation will show you which methods and properties you should use in your C# code. Alan.