Calcola il fattore di scala della pagina di impostazione
Contents
[
Hide
]
Quando si imposta il fattore di scala dell’impostazione della pagina utilizzando l’opzione Fit to n page(s) wide by m tall, Microsoft Excel calcola il Fattore di scala dell’impostazione della pagina. È possibile calcolare la stessa cosa utilizzando la proprietà SheetRender.PageScale. Questa proprietà restituisce un valore double che può essere convertito in valore percentuale. Ad esempio, se restituisce 0.5 significa che il fattore di scala è del 50%.
Il seguente codice di esempio illustra come calcolare il fattore di scala dell’impostazione della pagina utilizzando la proprietà SheetRender.PageScale.
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 | |
// Create workbook object | |
Workbook workbook = new Workbook(); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Put some data in these cells | |
worksheet.Cells["A4"].PutValue("Test"); | |
worksheet.Cells["S4"].PutValue("Test"); | |
// Set paper size | |
worksheet.PageSetup.PaperSize = PaperSizeType.PaperA4; | |
// Set fit to pages wide as 1 | |
worksheet.PageSetup.FitToPagesWide = 1; | |
// Calculate page scale via sheet render | |
SheetRender sr = new SheetRender(worksheet, new ImageOrPrintOptions()); | |
// Convert page scale double value to percentage | |
string strPageScale = sr.PageScale.ToString("0%"); | |
// Write the page scale value | |
Console.WriteLine(strPageScale); |