使用工作簿元数据
Contents
[
Hide
]
Aspose.Cells 允许您将轻量级版本的工作簿加载到内存中以编辑其元数据信息。请使用工作簿元数据加载工作簿的类。
下面的示例代码使用工作簿元数据类来编辑工作簿的自定义文档属性。使用打开工作簿后工作簿类,您将能够阅读文档属性。这是使用的示例代码工作簿元数据班级。
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); | |
// Open Workbook metadata | |
MetadataOptions options = new MetadataOptions(MetadataType.DocumentProperties); | |
WorkbookMetadata meta = new WorkbookMetadata(dataDir + "Sample1.xlsx", options); | |
// Set some properties | |
meta.CustomDocumentProperties.Add("test", "test"); | |
// Save the metadata info | |
meta.Save(dataDir + "Sample2.out.xlsx"); | |
// Open the workbook | |
Workbook w = new Workbook(dataDir + "Sample2.out.xlsx"); | |
// Read document property | |
Console.WriteLine(w.CustomDocumentProperties["test"]); | |
Console.WriteLine("Press any key to continue..."); | |
Console.ReadKey(); |