查找工作表是否为对话框工作表
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-Java | |
//Load Excel file containing Dialog Sheet | |
Workbook wb = new Workbook(srcDir + "sampleFindIfWorksheetIsDialogSheet.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.getWorksheets().get(0); | |
//Find if the sheet type is dialog and print the message | |
if(ws.getType() == SheetType.DIALOG) | |
{ | |
System.out.println("Worksheet is a Dialog Sheet."); | |
} |
控制台输出
Worksheet is a Dialog Sheet.