Using WorkbookMetadata
Contents
[
Hide
]
Aspose.Cells allows you to load a light-weight version of the workbook into memory to edit its metadata information. Please use the com.aspose.cells.WorkbookMetadata class to load the workbook.
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.
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-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")); |