获取或设置嵌入式OLE对象的类标识符
Contents
[
Hide
]
可能的使用场景
Aspose.Cells提供了OleObject.ClassIdentifier属性,您可以使用它来获取或设置嵌入ole对象的类标识符。OLE对象类标识符实际上是GUID,即全局唯一标识符。GUID始终是16个字节长,因此类标识符也是16个字节长。它们经常出现在Windows注册表中,并向宿主应用程序提供有关如何在客户端应用程序中打开嵌入的OLE对象的嵌入资源的信息。
获取或设置嵌入的OLE对象的类标识符
以下截图显示了从包含嵌入式PowerPoint OLE对象的示例Excel文件中读取的OLE对象类标识符即GUID。
示例代码
请参见以下使用示例Excel文件执行的样本代码和其控制台输出,该输出打印了OLE对象的类标识符即GUID。打印出的GUID与截图中显示的完全相同。
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 | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Load your sample workbook which contains embedded PowerPoint ole object | |
Workbook wb = new Workbook(dataDir + "sample.xls"); | |
// Access its first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
// Access first ole object inside the worksheet | |
OleObject oleObj = ws.OleObjects[0]; | |
// Convert 16-bytes array into GUID | |
Guid guid = new Guid(oleObj.ClassIdentifier); | |
// Print the GUID | |
Console.WriteLine(guid.ToString().ToUpper()); |
控制台输出
这是上述样本代码执行时与示例excel文件一起的控制台输出。
DC020317-E6E2-4A62-B9FA-B3EFE16626F4