使用WorkbookMetadata

Contents
[ ]

以下示例代码使用WorkbookMetadata类来编辑工作簿的自定义文档属性。一旦使用Workbook类打开工作簿,您将能够读取文档属性。以下是使用WorkbookMetadata类的示例代码。

// 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();