Powershell Excel Automation - Save/Open fails in Scheduled Task

后端 未结 2 1501
长发绾君心
长发绾君心 2021-01-13 14:10

I created a simple powershell script that will create an excel instance and save a workbook:

$excel = New-Object -ComObject Excel.Application
$workbook = $ex         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-13 14:44

    I remember having to do something similar in a C# application, which went well when you build it on Visual Studio, but running under a service on the CI server failed. This I believe is the limitation of Office Automation itself and Microsoft doesn't recommend / support doing this at all Look at Considerations for server-side Automation of Office here - http://support.microsoft.com/kb/257757. It shows the problems and the alternatives.

    In my case, I had to give up Office Interop, and use EPPlus ( http://epplus.codeplex.com/ ) to work with excel. It worked great and was much faster as well.

提交回复
热议问题