查找工作表是否为对话框工作表
Contents
[
Hide
]
可能的使用场景
对话工作表是一种包含对话框的工作表的旧格式。这样的工作表可能是由Microsoft Excel的旧版本(如2003)插入的,就像这张截图中所显示的一样。它也可以在较新版本的Microsoft Excel(如2016)中使用VBA插入。
您可以使用Aspose.Cells提供的Worksheet.Type属性来查找工作表是否是对话框工作表或其他类型的工作表。如果它返回枚举值SheetType.Dialog,那么表示您正在处理对话框工作表。
查找工作表是否为对话框工作表
以下示例代码加载包含对话框工作表的示例Excel文件。它检查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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Load Excel file containing Dialog Sheet | |
Workbook wb = new Workbook("sampleFindIfWorksheetIsDialogSheet.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
//Find if the sheet type is dialog and print the message | |
if (ws.Type == SheetType.Dialog) | |
{ | |
Console.WriteLine("Worksheet is a Dialog Sheet."); | |
} |
控制台输出
Worksheet is a Dialog Sheet.