在ASP.net C#中打印Excel文件 [英] Printing Excel file in ASP.net C#
问题描述
我使用互操作服务生成Excel文件,我可以将文件保存到服务器上.当我尝试使用以下代码进行打印时,如果我在本地运行,则会被打印.
worksheet.PrintOut(Type.Missing,Type.Missing,Type.Missing,Type.Missing,
Type.Missing,Type.Missing,Type.Missing,Type.Missing)
如果我将应用程序托管在IIS中,则这部分代码会出现错误
Microsoft Office Excel无法访问文件"D:\ file.xls".
Hi,
Iam generating a Excel file using interop services.I could save the file to my server. When i try to print using the below code it is printed if i run locally.
worksheet.PrintOut(Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing)
If i host the application in IIS ,i get error at this part of the code
Microsoft Office Excel cannot access the file ''D:\file.xls''.
Workbook.Open(filePath,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
我使用server.mappath保存文件.
请提出建议.
在此先感谢
I use server.mappath to save the file.
Suggestions please.
Thanks in advance
推荐答案
这总是有问题.您正在编写一个Web应用程序,因此您的代码在服务器上运行,而不是在客户端计算机上运行.实际发生的是您正在尝试在服务器上打印文档.
There will always be a problem with this. You are writing a web application so your code runs on the server, not the client''s machine. What is actually happening is that you are attempting to print the document on the server.
这篇关于在ASP.net C#中打印Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!