Excel自动化使用C#dynamic

我目前正在Silverlight 4中进行一个项目,在那里我需要将一些数据导出到Excel文件中。 使用dynamic关键字和AutomationFactory,我可以自动化Excel没有问题。

但是现在我想使用一些Excel枚举 – 我该怎么做? 我没有在我的项目中引用任何Interop-DLL,我只是使用dynamic。

例:

dynamic xlApp = null; //works without problems xlApp = AutomationFactory.CreateObject("Excel.Application"); xlApp.Visible = true; //doesn't work - 'Excel' does not exist, there are no referenced Interop-DLLs xlApp.Calculation = Excel.XlCalculation.xlCaculationManual 

这可能会解决你的问题:

 //set the Calculation to Manual xlApp.Calculation = -4135 

http://social.msdn.microsoft.com/Forums/en-US/exceldev/thread/13d1a55e-a138-4989-a4cd-2d986851a313/