查找工作表是否为对话框表
Contents
[
Hide
]
可能的使用场景
对话框工作表是一种包含对话框的工作表的旧格式。这样的工作表可以由旧版本的 Microsoft Excel(例如 2003)插入,如屏幕截图所示。它也可以在较新版本中使用 VBA 插入,例如 Microsoft Excel 2016。
查找工作表是否为对话框表
Aspose.Cells for Python via Java 使您能够检查工作表是否为对话框表。为此,它提供了工作表.类型财产。如果工作表.类型返回枚举值工作表类型.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.") |
控制台输出
工作表是一个对话框表。