Using WorkbookMetadata

Using WorkbookMetadata

The following sample code uses WorkbookMetadata class to edit custom document properties of a workbook. Once you open the workbook using Workbook class, you will be able to read the document properties.

Here is a sample code using the WorkbookMetadata class.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(UsingWorkbookMetadata.class);
// Open Workbook metadata
MetadataOptions options = new MetadataOptions(MetadataType.DOCUMENT_PROPERTIES);
WorkbookMetadata meta = new WorkbookMetadata(dataDir + "Sample1.xlsx", options);
// Set some properties
meta.getCustomDocumentProperties().add("test", "test");
// Save the metadata info
meta.save(dataDir + "Sample1.out.xlsx");
// Open the workbook
Workbook w = new Workbook(dataDir + "Sample1.out.xlsx");
// Read document property
System.out.println(w.getCustomDocumentProperties().get("test"));