Print multiple copies of a worksheet
Print multiple copies of a worksheet
Aspose.Cells for Python via .NET provides the ability to print multiple copies of a worksheet by using the SheetRender.to_printer(printer_settings) method. The following code snippet demonstrates the use of SheetRender.to_printer(printer_settings) method to print multiple copies of a worksheet. The following code snippet uses this sample excel file.
Sample Code
from aspose.cells import Workbook | |
from aspose.cells.rendering import ImageOrPrintOptions, SheetRender | |
import aspose.pydrawing as ad | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Source directory | |
sourceDir = RunExamples.Get_SourceDirectory() | |
# Load source Excel file | |
workbook = Workbook(sourceDir + "SheetRenderSample.xlsx") | |
imgOpt = ImageOrPrintOptions() | |
# Access first worksheet | |
worksheet = workbook.worksheets[1] | |
sheetRender = SheetRender(worksheet, imgOpt) | |
# Initialize PrinterSettings | |
printerSettings = ad.printing.PrinterSettings() | |
# Set printer name (example, it should be a valid printer name on your system) | |
printerSettings.printer_name = "Your Printer Name" | |
printerSettings.copies = 2 | |
sheetRender.to_printer(printerSettings) |