确定工作表的纸张尺寸是否为自动

可能的使用场景

大多数情况下,工作表的纸张大小是自动的。当它是自动的时候,通常设置为Letter。有时用户根据自己的需求设置工作表的纸张大小。在这种情况下,纸张大小不是自动的。您可以使用Worksheet.PageSetup.IsAutomaticPaperSize属性来查看工作表纸张大小是否为自动。

确定工作表的纸张大小是否自动

以下给出的示例代码加载以下两个Excel文件

并找到它们的第一个工作表的纸张尺寸是否为自动。在Microsoft Excel中,您可以通过页面设置窗口(如截图所示)检查纸张尺寸是否是自动的。

todo:image_alt_text

示例代码

// 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);

控制台输出

以下是上述示例代码在给定的示例Excel文件上执行时的控制台输出。

First Worksheet of First Workbook - IsAutomaticPaperSize: False

First Worksheet of Second Workbook - IsAutomaticPaperSize: True