Microsoft® Excel Dosyası Meta Verilerini Yönet via Java

Sunucu tarafı Java API'lerini kullanarak özel ve yerleşik Excel dosya özelliklerini görüntüleyin, ekleyin, güncelleyin, silin veya çıkarın.

 

JavaExcel API başlık, yazar adı, belge istatistikleri vb. gibi yerleşik (sistem tanımlı) özelliklerin yanı sıra ad/değer çifti biçimindeki özel (kullanıcı tanımlı) özelliklerin yönetimini destekler. Orada Çalışma kitabı sınıfı dosyaları yüklemek için ve Çalışma Sayfası Koleksiyonu çalışma sayfalarının toplanmasıyla da ilgilenir Çalışma sayfası sınıfı tek çalışma sayfasını temsil etmek için. Yerleşik ve özel özelliklere erişim için, BuildInDocumentProperties, CustomDocumentProperties, meta veri yönetimi sürecini basitleştirir.

Sistem Tanımlı Özellikleri Yönetme

Yerleşik özellikleri yönetmek için API şunları sağlar: DahiliDocumentÖzellikleri ve programcılar yerleşik bir özelliğe kolayca erişebilir ve değerini güncelleyebilir. Uygulama gereksinimine bağlı olarak geliştiriciler dizin veya özellik adını BelgeÖzellikKoleksiyonu .

Java Sistem Tanımlı Özellikleri Yönetme Kodu
//Create workbook object.
Workbook wb = new Workbook();
//Access system defined document property collection.
BuiltInDocumentPropertyCollection sdpc = wb.getBuiltInDocumentProperties();
//Set the language of the Excel file.
sdpc.setLanguage("German, French");
//Save the workbook.
wb.save(outputDir + "updated-builtin-document-properties.xlsx", SaveFormat.XLSX);
 

Özel Tanımlı Meta Veri Ekleme ve Kaldırma

Özel özelliklerin işlenmesi için API şunu sağlar: ÖzelBelgeÖzellikleri ve geliştiriciler mevcut mülklere kolayca erişebilir ve yeni mülkler ekleyebilirler. yöntem ekle ile ilgili CustomDocumentPropertyCollection class özelliği ekler ve yeni özellik için bir referansı döndürür. Properties.DocumentProperty nesne. DocumentProperty sınıfı, belge özelliğinin adını, değerini ve türünü şu şekilde almak için kullanılır: DocumentProperty.Name , DocumentProperty.Value , DocumentProperty.Type bu aşağıdakilerden birini döndürür Emlak Tipi numaralandırma değerleri.

Java Excel Dosyasına Meta Veri Ekleme Kodu
// Instantiate a Workbook object
// Open an Excel file
Workbook wkb = new Workbook(dataDir + "sample.xlsx");
// Retrieve a list of all custom document properties of the Excel file
CustomDocumentPropertyCollection customProperties = wkb.getWorksheets().getCustomDocumentProperties();
// Adding a custom document property to the Excel file
DocumentProperty publisher = customProperties.add("Publisher", "Aspose");
// Add link to content.
customProperties.addLinkToContent("Owner", "MyRange");
// Accessing the custom document property by using the property name
DocumentProperty customProperty1 = customProperties.get("Owner");
// Check whether the property is lined to content
Boolean islinkedtocontent = customProperty1.isLinkedToContent();
// Get the source for the property
String source = customProperty1.getSource();
// save the workbook
Java Excel Dosyasındaki Özel Özelliği Silme Kodu
// Instantiate a Workbook object
// Open an Excel file
Workbook wkb = new Workbook(dataDir + "sample.xlsx");
// Retrieve a list of all custom document properties of the Excel file
DocumentPropertyCollection customProperties = wkb.getWorksheets().getCustomDocumentProperties();
// Removing a custom document property
customProperties.remove("Publisher");