Printing Workbooks in xlsx4j

Aspose.Cells - Printing Workbooks

After you finish creating your spreadsheet, you will probably want to print a hard copy of the sheet for your needs. When printing, MS Excel assumes you want to print the entire worksheet area unless you specify a selection.

Printing Worksheet

Java

 //Instantiate a new workbook

Workbook book = new Workbook(dataDir + "AsposeDataInput.xls");

//Create an object for ImageOptions

ImageOrPrintOptions  imgOptions = new ImageOrPrintOptions ();

//Get the first worksheet

Worksheet sheet = book.getWorksheets().get(0);

//Create a SheetRender object with respect to your desired sheet

SheetRender sr = new SheetRender(sheet, imgOptions);

//Print the worksheet

sr.toPrinter("Samsung ML-1520 Series");

Printing Workbook

Java

 //Create a WorkbookRender object with respect to your workbook

WorkbookRender wr = new WorkbookRender(book, imgOptions);

//Print the workbook

wr.toPrinter("Samsung ML-1520 Series");

Download Running Code

Download Sample Code