Obtenga el ancho y el alto del papel de la configuración de página de la hoja de trabajo
Contents
[
Hide
]
Posibles escenarios de uso
veces, necesita saber el ancho y el alto del tamaño del papel tal como se configuró en la configuración de página de la hoja de trabajo. Por favor use elPageSetup.PaperWidthyPageSetup.PaperHeightpropiedades para este fin.
Obtenga el ancho y el alto del papel de la configuración de página de la hoja de trabajo
El siguiente código de ejemplo explica el uso dePageSetup.PaperWidth yPageSetup.PaperHeight propiedades. Primero cambia el tamaño del papel aA2y luego encuentra el ancho y la altura del papel, luego lo cambia aA3, A4, Cartay encuentra el ancho y la altura del papel respectivamente.
Código de muestra
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 an instance of Workbook class | |
Workbook book = new Workbook(); | |
// Access first worksheet | |
Worksheet sheet = book.Worksheets[0]; | |
// Set paper size to A2 and print paper width and height in inches | |
sheet.PageSetup.PaperSize = PaperSizeType.PaperA2; | |
Console.WriteLine("PaperA2: " + sheet.PageSetup.PaperWidth + "x" + sheet.PageSetup.PaperHeight); | |
// Set paper size to A3 and print paper width and height in inches | |
sheet.PageSetup.PaperSize = PaperSizeType.PaperA3; | |
Console.WriteLine("PaperA3: " + sheet.PageSetup.PaperWidth + "x" + sheet.PageSetup.PaperHeight); | |
// Set paper size to A4 and print paper width and height in inches | |
sheet.PageSetup.PaperSize = PaperSizeType.PaperA4; | |
Console.WriteLine("PaperA4: " + sheet.PageSetup.PaperWidth + "x" + sheet.PageSetup.PaperHeight); | |
// Set paper size to Letter and print paper width and height in inches | |
sheet.PageSetup.PaperSize = PaperSizeType.PaperLetter; | |
Console.WriteLine("PaperLetter: " + sheet.PageSetup.PaperWidth + "x" + sheet.PageSetup.PaperHeight); |
Salida de consola
Aquí está la salida de la consola del código de muestra anterior.
PaperA2: 16.54x23.39
PaperA3: 11.69x16.54
PaperA4: 8.27x11.69
PaperLetter: 8.5x11