Reputation: 1935
I face a problem on my application , I have a long running process , one of its outputs should be an excel file which has to be printed in background . The process will get a data from the remote server , and it has a predefined excel template then all I have to do to create the excel file and send it to the printer . I founded the ExcelPackage project and NOPI project which deals with excel files .
How to do that?
Upvotes: 1
Views: 2236
Reputation: 788
You can save the excel sheet programmatically and then use p/invoke ShellExecute with the "print" operation and the filename:
MSDN ShellExecute: http://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx
P/Invoke ShellExecute: http://www.pinvoke.net/default.aspx/shell32/ShellExecute.html
This will call the installed Excel version and tell it to open and print the given file on the default printer. Excel will close automatically after printing.
Upvotes: 3