Specify Job or Document Name while printing with Aspose.Cells
Contents
[
Hide
]
You can specify Job or Document Name while printing your workbook or worksheet using the WorkbookRender or SheetRender objects. Aspose.Cells for Python via .NET provides the WorkbookRender.ToPrinter(printerName, jobName) and SheetRender.ToPrinter(printerName, jobName) methods which you can use to specify Job Name while printing your workbook or worksheet
Specify Job or Document Name while printing with Aspose.Cells for Python via .NET
The sample code loads the source Excel file and then sends it to printer by specifying the job or document name using the WorkbookRender.ToPrinter(printerName, jobName) and SheetRender.ToPrinter(printerName, jobName) methods.
Sample Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.cells import Workbook | |
from aspose.cells.rendering import ImageOrPrintOptions, SheetRender, WorkbookRender | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Create workbook object from source Excel file | |
workbook = Workbook(dataDir + "SampleBook.xlsx") | |
printerName = "" | |
while null == printerName or "" == printerName: | |
print("Please Enter Your Printer Name:") | |
printerName = input() | |
jobName = "Job Name while Printing with Aspose.Cells" | |
# Print workbook using WorkbookRender | |
wr = WorkbookRender(workbook, ImageOrPrintOptions()) | |
try: | |
wr.to_printer(printerName, jobName) | |
except Exception as ex: | |
print(str(ex)) | |
# Access first worksheet | |
worksheet = workbook.worksheets[0] | |
# Print worksheet using SheetRender | |
sr = SheetRender(worksheet, ImageOrPrintOptions()) | |
try: | |
sr.to_printer(printerName, jobName) | |
except Exception as ex: | |
print(str(ex)) |