Spécifier le nom de l emploi ou du document lors de l impression avec Aspose.Cells

Spécifiez le nom du travail ou du document lors de l’impression avec Aspose.Cells pour Python via .NET

Le code d’exemple charge le fichier Excel source puis l’envoie à l’imprimante en spécifiant le nom du travail ou du document en utilisant les méthodes WorkbookRender.ToPrinter(nomImprimante, nomTravail) et SheetRender.ToPrinter(nomImprimante, nomTravail).

Code d’exemple

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))