We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Print Exce by duplex

I am using your aspose.cells for .net, I want to print excel by duplex,but I can not know how to do it,I can’t find any property or method to make it.I find this article in your bloc :How can I do duplex printing?, however ,it can not make it yet.so I need your help.If you can help me , I will be deeply appreciate.
Thanks a lot for your due attention to this article,I am looking forward to your prompt reply at your earliest convenience.

@h1138289016

Thanks for using Aspose APIs.

When you will run the code, it will show you names of printers on your PC. You will select one of them and then it will do the printing. Here is a screenshot of the sample code with correct formatting.

Screenshot:

C#

using System;
using System.Collections;
using System.Drawing.Printing;
using Aspose.Cells;
using Aspose.Cells.Rendering;

namespace TestAspose
{
    class Test
    {
        private SheetRender sr = null;

        private PrintDocument pd = new System.Drawing.Printing.PrintDocument();

        public void ToPrinter()
        {
            Workbook book = new Workbook(@"f:/download/Test.xlsx");

            ImageOrPrintOptions io = new ImageOrPrintOptions();
            io.ImageFormat = System.Drawing.Imaging.ImageFormat.Tiff;

            ArrayList prnLst = new ArrayList(PrinterSettings.InstalledPrinters);
            prnLst.Sort();

            Console.WriteLine("Total printers installed: {0}\n", prnLst.Count);

            foreach (string printer in prnLst)
            {
                Console.WriteLine("\t- {0}", printer);
            }

            String readLine = Console.ReadLine();

            PrintPageEventHandler pe = new PrintPageEventHandler(PrintPage);
            io.CustomPrintPageEventHandler = pe;

            foreach (Worksheet ws in book.Worksheets)
            {
                sr = new SheetRender(ws, io);
                sr.ToPrinter((string)prnLst[int.Parse(readLine) - 1]);
            }
        }


        void PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs ev)
        {
            ev.PageSettings.PrinterSettings.Duplex = Duplex.Default;

            int currentIndex = sr.CustomPrint(true, ev);

            if (currentIndex != sr.PageCount)
                ev.HasMorePages = true;
            else
                ev.HasMorePages = false;
        }
    }
}