?
Solved

Print Excel C#

Posted on 2007-08-09
3
Medium Priority
?
2,964 Views
Last Modified: 2008-01-09
Printing excel file in C# without opening file
0
Comment
Question by:quocnm0066
3 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 600 total points
ID: 19662144
0
 
LVL 7

Assisted Solution

by:badbearontour
badbearontour earned 300 total points
ID: 19662157
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.

BB
0
 
LVL 3

Assisted Solution

by:Pigtor
Pigtor earned 600 total points
ID: 19670588
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);
xls.Quit();


I hope that helps
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Integration Management Part 2
Loops Section Overview
Suggested Courses
Course of the Month16 days, 15 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question