trakos
trakos

Reputation: 841

How to integrate application with excel macros?

I have to find the best way to integrate my application with excel. Basically, I have to make some fancy frontend for filling input data, and later showing the output. The calculations have to be made in .VBA macro. Basically:

  1. Fill some fields at excel worksheet.
  2. Run macro.
  3. Fetch data from specific columns.

What we did before was to have excel .vba macro be auto-execute on open, fetch data from file, and then output it to another one. Then the application would just have to write input data to file, exec .xls and wait for output file. This approach obviously has many limitations: no error reporting, having to wait for file to appear, lots of hustle to get filepaths correct.

Are there any good ways to achieve that, for example using some .NET magic? I am open to all solutions, including all kind of technologies and languages ;)

Upvotes: 0

Views: 1371

Answers (1)

Marco
Marco

Reputation: 57573

You could try using Excel.Interop developed in framework.
So you could open your excel file and then:

  1. Fill some fields using Interop
  2. Run macro with code containded in this link
  3. Fetch data using Interop

In this link you can find something useful with Excel.Interop.
Anyway if you search "C# Excel example" in Google you find tons of examples...

Upvotes: 1

Related Questions