查找工作表是否为对话框工作表
Contents
[
Hide
]
可能的使用场景
对话框工作表是包含对话框的旧格式的工作表。此类工作表可以由较旧版本的 Microsoft Excel(如2003年)插入,如下图所示。它也可以在较新版本(如 Microsoft Excel 2016)中使用 VBA 插入。
查找工作表是否为对话框工作表
Aspose.Cells for Python via Java提供了检查工作表是否为对话框工作表的功能。为此,它提供了Worksheet.Type属性。如果Worksheet.Type返回枚举值SheetType.DIALOG,那么意味着你正在处理对话框工作表。
以下代码段显示了如何检查对话框工作表。代码生成的控制台输出如下所示。
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
source_directory = "Examples/SampleFiles/SourceDirectory/" | |
# Load Excel file containing Dialog Sheet | |
workbook = Workbook(source_directory + "sampleFindIfWorksheetIsDialogSheet.xlsx") | |
# Access first worksheet | |
worksheet = workbook.getWorksheets().get(0) | |
# Find if the sheet type is dialog and print the message | |
if worksheet.getType() == SheetType.DIALOG: | |
print("Worksheet is a Dialog Sheet.") |
控制台输出
Worksheet is a Dialog Sheet.