تحديد مهمة أو اسم الوثيقة أثناء الطباعة باستخدام Aspose.Cells
Contents
[
Hide
]
يمكنك تحديد اسم الوظيفة أو المستند أثناء طباعة دفتر العمل أو ورقة العمل الخاصة بك باستخدام كائنات WorkbookRender أو SheetRender. يوفر Aspose.Cells للبايثون via .NET الطرق WorkbookRender.ToPrinter(printerName, jobName) و SheetRender.ToPrinter(printerName, jobName) التي يمكنك استخدامها لتحديد اسم الوظيفة أثناء طباعة دفتر العمل أو ورقة العمل.
حدد اسم الوظيفة أو المستند أثناء الطباعة باستخدام Aspose.Cells للبايثون via .NET
تحمل الشفرة العينية الملف العيني لل Excel ومن ثم ترسله إلى الطابعة عن طريق تحديد مهمة أو اسم الوثيقة باستخدام أساليب WorkbookRender.ToPrinter(printerName, jobName) و SheetRender.ToPrinter(printerName, jobName).
الكود المثالي
This file contains hidden or 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)) |