Click here to Skip to main content
15,898,538 members
Please Sign up or sign in to vote.
4.67/5 (3 votes)
See more:
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'.

C#
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);


I use server.mappath to save the file.
Suggestions please.

Thanks in advance
Posted
Updated 2-Nov-12 3:27am
v2

1 solution

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.
 
Share this answer
 
Comments
Sandeep Mewara 2-Nov-12 12:26pm    
Correct. My 5!

OT: Can you please have a look at this article and share how is it?
http://www.codeproject.com/Articles/487972/WPF-Textbox-extended-to-Custom-Picker
abc0077 5-Nov-12 2:50am    
Hi Marcus,

Yes that's true , but what could be the solution or work around for this.

thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900