Print Excel C#

Printing excel file in C# without opening file
Who is Participating?
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
badbearontourConnect With a Mentor Commented:
I dont think you can print it as though it was a excel sheet without opening the file

You have to create a excel object and use the object to print the file.

PigtorConnect With a Mentor Commented:
You must use the Microsoft Object Library found in the COM references list.
And try this code:

Excel.Application xls = new Excel.Application();
Excel.Workbook wrk = xls.Workbooks.Open("c:\\report.txt", 0, true, 5, string.Empty, string.Empty, true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true);
wrk.PrintOut(1, 1, 1, false, null, false, false, null);
wrk.Close(false, string.Empty, false);

I hope that helps
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.