Aspose.Cells ile yazdırırken İş veya Belge Adı belirtin

Aspose.Cells ile Yazdırırken İş veya Belge Adını Belirtme

Örnek kod, kaynak Excel dosyasını yükler ve ardından WorkbookRender.ToPrinter(yazıcıAdı, işAdı) ve SheetRender.ToPrinter(yazıcıAdı, işAdı) metodlarını kullanarak belirli iş veya belge adı belirterek yazıcıya gönderir.

Örnek Kod

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create workbook object from source Excel file
Workbook workbook = new Workbook(dataDir + "SampleBook.xlsx");
string printerName = "";
while (string.IsNullOrEmpty(printerName) && string.IsNullOrWhiteSpace(printerName))
{
Console.WriteLine("Please Enter Your Printer Name:");
printerName = Console.ReadLine();
}
string jobName = "Job Name while Printing with Aspose.Cells";
// Print workbook using WorkbookRender
WorkbookRender wr = new WorkbookRender(workbook, new ImageOrPrintOptions());
try
{
wr.ToPrinter(printerName, jobName);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Print worksheet using SheetRender
SheetRender sr = new SheetRender(worksheet, new ImageOrPrintOptions());
try
{
sr.ToPrinter(printerName, jobName);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}