Determina se la dimensione carta del foglio di lavoro è automatica
Possibili Scenari di Utilizzo
Molte volte, la dimensione carta del foglio di lavoro è automatica. Quando è automatica, spesso è impostata come Lettera. A volte l’utente imposta la dimensione carta del foglio di lavoro in base alle proprie esigenze. In questo caso, la dimensione carta non è automatica. Puoi scoprire se la dimensione carta del foglio di lavoro è automatica o meno utilizzando la proprietà Worksheet.PageSetup.IsAutomaticPaperSize.
Determina se le dimensioni del foglio di lavoro sono automatiche
Il codice di esempio riportato di seguito carica i seguenti due file Excel
e verifica se la dimensione carta del loro primo foglio di lavoro è automatica o meno. In Microsoft Excel, puoi verificare se la dimensione carta è automatica o meno tramite la finestra Impostazioni pagina come mostrato in questa immagine.
Codice di Esempio
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Load the first workbook having automatic paper size false | |
Workbook wb1 = new Workbook(sourceDir + "samplePageSetupIsAutomaticPaperSize-False.xlsx"); | |
//Load the second workbook having automatic paper size true | |
Workbook wb2 = new Workbook(sourceDir + "samplePageSetupIsAutomaticPaperSize-True.xlsx"); | |
//Access first worksheet of both workbooks | |
Worksheet ws11 = wb1.Worksheets[0]; | |
Worksheet ws12 = wb2.Worksheets[0]; | |
//Print the PageSetup.IsAutomaticPaperSize property of both worksheets | |
Console.WriteLine("First Worksheet of First Workbook - IsAutomaticPaperSize: " + ws11.PageSetup.IsAutomaticPaperSize); | |
Console.WriteLine("First Worksheet of Second Workbook - IsAutomaticPaperSize: " + ws12.PageSetup.IsAutomaticPaperSize); |
Output della console
Ecco l’output sulla console del codice di esempio sopra quando eseguito con i file Excel di esempio forniti.
First Worksheet of First Workbook - IsAutomaticPaperSize: False
First Worksheet of Second Workbook - IsAutomaticPaperSize: True