Windows Server 2008进行服务运行解析Excel出错

被这个shit问题搞了好几天了,简直晕了。

问题:做一个在SharePoint 2010中上传Excel并解析,导入SPList的功能。

环境:Windows Server 2008 x64, SharePoint 2010, Visual Studio 2010

先做了一个Asp.net Web Application,功能测试通过,然后以应用程序页面方式,部署在SharePoint 2010中,一上传Excel在如下语句运行即报错。

...

workbook = app.Application.Workbooks._Open(fileFullName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);

...

这是非常正常的Excel打开方式,在Asp.net和控制台程序中都可以运行。唯独放在SharePoint 2010中就是出错。错误信息如下。

 

Microsoft Office Excel 不能访问文件“”。 可能的原因有:

• 文件名称或路径不存在。
• 文件正被其他程序使用。
• 您正要保存的工作簿与当前打开的工作簿同名。

一直以为与SharePoint有关系,所有可能试过的都试过了,就是不行...崩溃,最后找到了答案,吐血...

摘自: http://social.msdn.microsoft.com/Forums/en-SG/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91

 

This solution is ...

・Windows 2008 Server x64

  Please make this folder.

  C:\Windows\SysWOW64\config\systemprofile\Desktop

・Windows 2008 Server x86

  Please make this folder.

  C:\Windows\System32\config\systemprofile\Desktop

 

最好是两个目录都创建,我的环境是Windows Server 2008 R2 x64,按照第一个解决方法不灵,又创建个目录,就好了。

 

posted @ 2010-07-18 22:20  泡饭  阅读(773)  评论(0编辑  收藏  举报