开发者

Mapping between Excel and XML file - How to refresh from C#

开发者 https://www.devze.com 2022-12-30 09:39 出处:网络
Got an excel spread sheet where I specify mapping to an XML file. I\'d like to open the spread sheet from C# and force refresh the cells mappped to the XML file.

Got an excel spread sheet where I specify mapping to an XML file.

I'd like to open the spread sheet from C# and force refresh the cells mappped to the XML file. -> How can I 开发者_如何学编程do that ? Any dll I need to reference ?

Thanks

Olivier


You have not specified your requirements, but this is fairly easy using the handy "macro recorder" feature of Excel to get the needed "API" and Visual Studio Tools for Office (VSTO) at http://msdn.microsoft.com/en-us/vsto/default.aspx provides the functionality you need in order to use C#.

  1. In Excel, record a macro that refreshes the XML Mapping.
  2. In C#,
    • Using VSTO, duplicate the macro.
    • Using VSTO, create a project, see what assemblies are referenced, add those references to your project, then duplicate the macro.

Obviously, the devil is in the details, but this will get you started.


Have you had a look at VSTO. VSTO allows you to call .NET code and therefore it might be easier to manage what is happening.

Might be worthwhile taking a peek^^


I am not no sure about what you mean by mapping XML file, but you should be able to use excel PIA and invoke calculate() on each sheet, forcing all cells to refresh.

0

精彩评论

暂无评论...
验证码 换一张
取 消