Print Excel C#

Posted on 2007-08-09
Last Modified: 2008-01-09
Printing excel file in C# without opening file
Question by:quocnm0066
    LVL 69

    Accepted Solution

    LVL 7

    Assisted Solution

    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.

    LVL 3

    Assisted Solution

    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

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now