我在使用 PDFCreator 从 Excel 宏(使用 VB.NET 3.5 和 Interop)生成 PDF 文件时遇到问题。
通过以域用户身份登录 Windows,我可以直接从 Excel 运行宏,一切正常(打印并保存 pdf 文件),但是当从服务器以同一用户身份发布和运行时,找不到打印机。
在宏中,我知道这可以通过设置 Application.ActivePrinter (在我的例子中为“Ne00 上的 PDFCreator:”)来解决,当我直接从 Excel 运行而不是从服务器运行时,它再次起作用。那么我想知道如何在服务器上运行时设置ActivePrinter?
它可以与服务器上以前的 IIS 版本 (6.0) 一起使用。我尝试授予域用户访问权限(例如在 DCOMCNFG 中),PDFCreator 设置正确且可访问,但我真的不知道如何解决此问题。
I'm having trouble generating a PDF-file with PDFCreator from Excel macro (using VB.NET 3.5 and Interop).
Through Windows login as the domain user I can run the macro directly from Excel and everything works fine (a pdf file is printed and saved), but when published and run as the same user from server there is no printer found.
In the macro I know this can be solved by setting Application.ActivePrinter ("PDFCreator on Ne00:" in my case), which again works when I run directly from Excel but not from server. So what I wonder is how to make it possible to set ActivePrinter when running on server?
It worked with previous IIS version on the server (6.0). I have tried giving the domain user access permissions (e.g. in DCOMCNFG), the PDFCreator is set up correctly and accessible, don't really know how to approach this.
发布评论
评论(2)
MS 不支持在类似服务器的方案(IIS/ASP.NET/Windows 服务...)中使用 Office Interop - 请参阅http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2
另一点是,自 Windows Vista 以来,出现了一些与安全相关的更改这会阻止从 Windows 服务执行任何“类似桌面”的操作(例如打印...)...
Interop 的替代方案:
要从 Excel 文件创建 PDF,有几个库可以执行以下操作:不使用 Excel 并且工作正常服务器场景 - 例如 Flexcel、Aspose.Cells,SpreadsheetGear...
Using Office Interop from server-like scenarios (IIS/ASP.NET/Windows Service...) is NOT supported by MS - see http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2
Another point is that since windows vista there have been several security-related changed which prevent doing any "desktop-like" things (for example printing...) from a Windows Service...
Alternative to Interop:
To create PDF from Excel file there are several libraries out there which do not use Excel and work fine in server-scenarios - like Flexcel, Aspose.Cells, SpreadsheetGear...
即使在 IIS8 中也能工作。
为 Microsoft Excel 应用程序提供 DcomConfig 足够的权限(例如 IIS_IUSRS、网络服务等),
负责模拟 Web.xml 中提供的用户 ID 和密码。如无必要,请勿将其变为真。当我删除它时它对我有用。
It works even in IIS8 also.
Give Microsoft Excel Application sufficient Permission from DcomConfig (Eg-IIS_IUSRS,Network Services etc)
take care of impersonate user id and password provided In Web.xml. do not make it true if not necessary. it worked for me when i removed this.