使用Aspose.Cells打印工作簿

Aspose.Cells - 打印工作簿

完成创建电子表格后,您可能希望打印工作表的硬拷贝以满足您的需求。在打印时,MS Excel会假定您要打印整个工作表区域,除非您指定您的选择。

打印工作表

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

打印工作簿

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

下载运行代码

下载示例代码