1

I have an excel workbook which needs to query data from an HTTP server. Query directly from a remote database isn't an option.

From what I know I can use VB macros to contact the HTTP server and update the cells in the workbook. Is it possible to do this in C#? I don't want to additional burden of deploying an extra application.

Thanks for your help.

5
  • You could perhaps set up a local database on a local server and have a C# application keep an up-to-date local cache. Commented Jun 30, 2012 at 18:34
  • I've got this covered stay tuned... Commented Jun 30, 2012 at 18:59
  • @J... - that's not an option. Commented Jul 1, 2012 at 7:02
  • @JeremyThompson - looking forward to it! Commented Jul 1, 2012 at 7:03
  • @Remou - i don't have a separate C# application. Would preferably want to deploy just the excel file Commented Jul 1, 2012 at 7:07

2 Answers 2

3

You can use the VSTO to create a document or application level addin to Excel. Look here http://msdn.microsoft.com/en-us/office/hh128771.aspx

Sign up to request clarification or add additional context in comments.

2 Comments

the document level customization mentioned in the link might just be exactly what I'm looking for. Thanks a bunch!
if this is exactly what you need, please mark this post as the answer to your question
1

Follow the first couple of repro steps here to create a Visual Studio Tools for Office - Excel Add-In.

Skip the last step about the calender control.

In the Excel AddIn Project > add a Ribbon Bar and Button and you can invoke methods to collect the data via http and refresh the workbook. Everything in VSTO is pretty much the exact same way you would do it in VBA but in C# syntax.

Extend Your VBA Code With VSTO

When it comes to deploying you should use a Setup Project and it will create an MSI. If you have a App.Config file be aware when deploying you need to set the setup project to add a registry key: https://stackoverflow.com/a/10525693/495455

I highly recommend this blog for tips on better VSTO memory management via .Net code: http://jake.ginnivan.net/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.