Documents for Excel .NET Edition | GCDocuments
Features / Print
In This Topic
    Print
    In This Topic

    GcExcel.NET allows you to output a workbook or worksheet to a printer using the PrintOut method provided by IWorkbook and IWorksheet interface respectively. This method accepts object of PrintOutOptions class as a parameter. In the background, PrintOut method uses GcPdf to print workbook to a printer. Hence, you need to reference GrapeCity.Documents.Imaging.Windows to implement the feature.

    Note: The PrintOut method works only on the Windows environment. To print in other environments, you can export the document to PDF and then take a print of the converted document. For information on exporting a spreadsheet to PDF, see Export to PDF.

    Print Options

    GcExcel.NET provides PrintOutOptions class that contains various properties and events to set printing options such as printer name, number of copies, first and last page to be printed etc. To print a document with specified printing options, you need to create an instance of the PrintOutOptions class, define the options for that instance and pass that instance while calling the PrintOut method.

    C#
    Copy Code
    //Create an instance of PrintOutOptions class
    PrintOutOptions options = new PrintOutOptions();
    
    //Set name of the target printer
    options.ActivePrinter = "Microsoft Print to PDF";
            
    //Print 3 copies
    options.Copies = 3;
    
    //Print this workbook
    workbook.PrintOut(options);
    
    //Save to an excel file
    workbook.Save("printworkbook.xlsx");