ワークブックの印刷
Contents
[
Hide
]
このドキュメントは、開発者がスプレッドシートを印刷する方法を (簡潔に) 理解できるようにすることを目的としています。
利用シーン
スプレッドシートの作成が完了したら、必要に応じてシートのハード コピーを印刷することをお勧めします。印刷するとき、MS Excel は、選択を指定しない限り、ワークシート領域全体を印刷すると想定します。次のスクリーンショットは、Excel でワークブックを印刷するためのダイアログ ボックスを示しています。
**形:**印刷ダイアログボックス
Aspose.Cells を使用したワークブックの印刷
Aspose.Cells for Java は、[プリンターへ](https://reference.aspose.com/cells/java/com.aspose.cells/sheetrender#toPrinter(java.lang.String) の方法シートレンダリングクラス。を使用することにより、SheetRender.toPrinter メソッドでは、印刷ジョブ名だけでなくプリンター名も指定できます。
サンプルコード
選択したワークシートを印刷
次のコード スニペットは、[SheetRender.toPrinter](https://reference.aspose.com/cells/java/com.aspose.cells/sheetrender#toPrinter(java.lang.String)メソッドを使用して、選択したワークシートを印刷します。
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
// 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(PrintingSelectedWorksheet.class); | |
// Instantiate a new workbook | |
Workbook book = new Workbook(dataDir + "Book1.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(strPrinterName); |
ワークブック全体を印刷
また、WorkbookRender.toPrinter ワークブック全体を印刷するメソッド。次のコード スニペットは、WorkbookRender.toPrinter ワークブック全体を印刷するメソッド。
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
// 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(PrintingWholeWorkbook.class); | |
// Instantiate a new workbook | |
Workbook book = new Workbook(dataDir + "Book1.xls"); | |
// Create an object for ImageOptions | |
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions(); | |
// WorkbookRender only support TIFF file format | |
imgOptions.setImageFormat(ImageFormat.getTiff()); | |
// Create a WorkbookRender object with respect to your workbook | |
WorkbookRender wr = new WorkbookRender(book, imgOptions); | |
// Print the workbook | |
wr.toPrinter(strPrinterName); |