HTMLに印刷エリア範囲をエクスポートする
Contents
[
Hide
]
可能な使用シナリオ
PDFレンダリングにはすでに利用可能な機能ですが、HTMLにも適用可能な、ワークシートの選択範囲である印刷範囲のみをエクスポートする場合があります。ワークシートのページ設定オブジェクトに印刷範囲を設定し、後でHtmlSaveOptions.ExportPrintAreaOnlyフラグを使用して選択範囲のみをエクスポートしてください。
サンプルコード
次のサンプルコードはワークブックをロードし、プリントエリアをHTMLにエクスポートします。この機能のテスト用にサンプルファイルを以下のリンクからダウンロードできます。
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-.NET | |
// Load the Excel file. | |
Workbook wb = new Workbook(sourceDir + "sampleInlineCharts.xlsx"); | |
// Access the sheet | |
Worksheet ws = wb.Worksheets[0]; | |
// Set the print area. | |
ws.PageSetup.PrintArea = "D2:M20"; | |
// Initialize HtmlSaveOptions | |
HtmlSaveOptions options = new HtmlSaveOptions(); | |
// Set flag to export print area only | |
options.ExportPrintAreaOnly = true; | |
//Save to HTML format | |
wb.Save(outputDir + "outputInlineCharts.html", options); |