Esportare l area di stampa in HTML
Contents
[
Hide
]
Possibili Scenari di Utilizzo
Questo è uno scenario comune in cui è necessario esportare solo l’area di stampa, ovvero la gamma selezionata di celle anziché l’intero foglio in HTML. Questa funzionalità è già disponibile per la resa in PDF, tuttavia, ora puoi eseguire questa attività anche per l’HTML. Imposta prima l’area di stampa nell’oggetto di impostazione pagina del foglio di lavoro. Successivamente, utilizza il flag HtmlSaveOptions.ExportPrintAreaOnly per esportare solo la gamma selezionata.
Codice di esempio
Il codice di esempio seguente carica un libro di lavoro e quindi esporta l’area di stampa in HTML. Il file di esempio per testare questa funzionalità può essere scaricato dal seguente link:
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); |