查找工作表是否为对话框工作表

可能的使用场景

对话工作表是一种包含对话框的工作表的旧格式。这样的工作表可能是由Microsoft Excel的旧版本(如2003)插入的,就像这张截图中所显示的一样。它也可以在较新版本的Microsoft Excel(如2016)中使用VBA插入。

todo:image_alt_text

您可以使用Aspose.Cells for Python via .NET提供的Worksheet.type属性来查看工作表是否是对话表或其他类型的表。如果返回枚举值SheetType.DIALOG,那么表示您正在处理对话表。

查找工作表是否为对话框工作表

以下示例代码加载包含对话框工作表的示例Excel文件。它检查Worksheet.type属性并将其与SheetType.DIALOG进行比较,然后打印消息。请参阅下面给出的示例代码的控制台输出以获取更多帮助。

示例代码

from aspose.cells import SheetType, Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Load Excel file containing Dialog Sheet
wb = Workbook("sampleFindIfWorksheetIsDialogSheet.xlsx")
# Access first worksheet
ws = wb.worksheets[0]
# Find if the sheet type is dialog and print the message
if ws.type == SheetType.DIALOG:
print("Worksheet is a Dialog Sheet.")

控制台输出

Worksheet is a Dialog Sheet.