Windows Server 2008 R2上跑基于Microsoft Excel Object Library 的报表程序,报错不能访问文件

企业应用中后台常常会跑一些生成、发送Excel报表的程序。app

.NET应用程序生成Excel文件,基本上有2种方法:this

1.Microsoft Excel XX Object Library (Interop.Excel.DLL文件)spa

2.NPOI开发

虽说NPOI很快,可是Excel XX Object Library是很是方便的,代码能够参考Excel中录制的宏代码。it

前段时间就遇到一个问题:.NET开发的基于Microsoft Excel XX Object Library 报表程序在Windows Server 2008 R2上运行。报错:io

Microsoft Office Excel 不能访问文件“XX.xls”。 可能的缘由有:模板

? 文件名称或路径不存在。
? 文件正被其余程序使用。
? 您正要保存的工做簿与当前打开的工做簿同名
后台

XX.xls就是模板文件。真是百思不得其解。file

在网上查找了一圈找到了解办法:程序

?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

  ...instead of dcomcnfg.exe.

This operation took away office automation problems in my system.

A Desktop folder seems to be necessary in the systemprofile folder to open file by Excel.

It disappears from Windows2008, Windows2003 had the folder,
and I think it cause this error.

也就是:

C:\Windows\System32\config\systemprofile和C:\Windows\SysWOW64\config\systemprofile目录下建立名为Desktop目录便可解决问题

相关文章
相关标签/搜索