用C++查找工作表是否为对话框工作表
Contents
[
Hide
]
可能的使用场景
对话工作表是一种包含对话框的工作表的旧格式。这样的工作表可能是由Microsoft Excel的旧版本(如2003)插入的,就像这张截图中所显示的一样。它也可以在较新版本的Microsoft Excel(如2016)中使用VBA插入。
可以使用Aspose.Cells的Worksheet.GetType()属性判断工作表是否为对话框工作表。如果返回枚举值SheetType.Dialog,则表示该工作表为对话框工作表。
查找工作表是否为对话框工作表
以下示例代码加载包含对话框工作表的示例Excel文件(64716820.xlsx),检查Worksheet.GetType()属性并与SheetType.Dialog比较,然后输出结果信息。详见下方控制台输出。
示例代码
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Load Excel file containing Dialog Sheet
Workbook workbook(u"sampleFindIfWorksheetIsDialogSheet.xlsx");
// Access first worksheet
Worksheet ws = workbook.GetWorksheets().Get(0);
// Find if the sheet type is dialog and print the message
if (ws.GetType() == SheetType::Dialog)
{
std::cout << "Worksheet is a Dialog Sheet." << std::endl;
}
Aspose::Cells::Cleanup();
}
控制台输出
Worksheet is a Dialog Sheet.