如何将应用程序与excel宏集成? [英] How to integrate application with excel macros?

查看:137
本文介绍了如何将应用程序与excel宏集成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须找到最好的方法来整合我的应用程序与excel。基本上,我必须做一些花哨的前端填充输入数据,然后显示输出。必须在.VBA宏中进行计算。基本上:

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. 在excel工作表中填写一些字段。

  2. 运行宏。

  3. 从特定列中获取数据。

我们以前做过的是将.vba宏自动执行打开,从文件获取数据,然后将其输出到另一个。那么应用程序只需要将输入数据写入文件exec .xls并等待输出文件。这种方法显然有很多限制:没有错误报告,不得不等待文件出现,很多匆忙获取文件路径正确。

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.

有没有什么好的方法来实现,例如使用一些.NET魔术?我对所有解决方案开放,包括各种技术和语言;)

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 ;)

推荐答案

您可以尝试使用Excel.Interop开发框架。

所以你可以打开你的excel文件,然后:

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


  1. 使用Interop填充一些字段

  2. 使用此链接中包含的代码运行宏

  3. 使用Interop获取数据

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

在这个链接,您可以找到Excel.Interop中有用的东西。

无论如何,如果您在Google中搜索C#Excel示例,您会发现吨的例子...

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...

这篇关于如何将应用程序与excel宏集成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆