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 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
The sample code loads the source Excel file and then sends it to the printer by specifying the job or document name using the WorkbookRender.toPrinter(printerName, jobName) and SheetRender.toPrinter(printerName, jobName) methods. The screenshot shows how the job name looks like in the printer queue.
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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SpecifyJoborDocumentName.class); | |
// Create workbook object from source Excel file | |
Workbook workbook = new Workbook(dataDir + "source.xlsx"); | |
// Specify Printer and Job Name | |
String printerName = "doPDF v7"; | |
String jobName = "Job Name while Printing with Aspose.Cells"; | |
// Print workbook using WorkbookRender | |
WorkbookRender wr = new WorkbookRender(workbook, new ImageOrPrintOptions()); | |
wr.toPrinter(printerName, jobName); | |
// Access first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Print worksheet using SheetRender | |
SheetRender sr = new SheetRender(worksheet, new ImageOrPrintOptions()); | |
sr.toPrinter(printerName, jobName); | |