إدارة Microsoft® بيانات تعريف ملف Excel via Java
عرض أو إضافة أو تحديث أو حذف أو استخراج خصائص ملف Excel المخصصة والمضمنة باستخدام واجهات برمجة التطبيقات Java من جانب الخادم.
Java اكسل API يدعم إدارة الخصائص المضمنة (المحددة من قبل النظام) مثل العنوان واسم المؤلف وإحصائيات المستند وما إلى ذلك بالإضافة إلى الخصائص المخصصة (المحددة من قبل المستخدم) في شكل زوج الاسم/القيمة. هنالك فئة المصنف لتحميل الملفات، و مجموعة أوراق العمل يتعامل مع مجموعة من أوراق العمل كذلك فئة ورقة العمل لتمثيل ورقة عمل واحدة. للوصول إلى الخصائص المضمنة والمخصصة، BuildInDocumentProperties، CustomDocumentProperties تجعل العملية بسيطة لإدارة بيانات التعريف.
إدارة الخصائص المحددة للنظام
لإدارة العقارات المدمجة، يوفر API بنيتInDocumentProperties ويمكن للمبرمجين الوصول بسهولة إلى خاصية مدمجة وتحديث قيمتها. اعتمادًا على متطلبات التطبيق، يمكن للمطورين استخدام الفهرس أو اسم الخاصية من ملف DocumentPropertyCollection .
Java كود لإدارة خصائص النظام المحددة
//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); |
إضافة وإزالة البيانات التعريفية المحددة المخصصة
للتعامل مع الخصائص المخصصة، يوفر API خصائص المستند المخصص ويمكن للمطورين الوصول بسهولة إلى العقارات الموجودة بالإضافة إلى إضافة خصائص جديدة باستخدام إضافة طريقة ل CustomDocumentPropertyCollection تضيف الفئة الخاصية وترجع مرجعًا للخاصية الجديدة باعتبارها خصائص.DocumentProperty هدف. يتم استخدام فئة DocumentProperty لاسترداد اسم وقيمة ونوع خاصية المستند كـ DocumentProperty.Name , DocumentProperty.Value , DocumentProperty.Type التي ترجع واحدة من نوع الملكية قيم التعداد.
Java كود اضافة البيانات الوصفية في ملف الاكسل
// 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 كود حذف خاصية مخصصة في ملف إكسل
// 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"); |