إدارة Microsoft® بيانات تعريف ملف Excel via .NET
عرض أو إضافة أو تحديث أو إزالة أو استخراج خصائص ملف Excel المضمنة والمخصصة باستخدام واجهات برمجة التطبيقات .NET من جانب الخادم.
.NET اكسل API يدعم إدارة الخصائص المحددة من قبل النظام (المدمجة) مثل العنوان واسم المؤلف وإحصائيات المستند وما إلى ذلك بالإضافة إلى الخصائص المحددة من قبل المستخدم (المخصصة) في شكل زوج من الاسم والقيمة. هنالك فئة المصنف لتحميل الملفات، و مجموعة أوراق العمل يتعامل مع مجموعة من أوراق العمل كذلك فئة ورقة العمل لتمثيل ورقة عمل واحدة. جنبا إلى جنب مع هذه الفئات، BuildInDocumentProperties، CustomDocumentProperties تجعل العملية بسيطة لإدارة بيانات التعريف.
إدارة الخصائص المضمنة
لإدارة الخصائص المحددة من قبل النظام، يوفر API بنيتInDocumentProperties ويمكن للمبرمجين الوصول بسهولة إلى خاصية مدمجة وتحديث قيمتها. اعتمادًا على متطلبات التطبيق، يمكن للمطورين استخدام الفهرس أو اسم الخاصية من ملف DocumentPropertyCollection .
C# كود لإدارة العقارات المبنية
//Create workbook object. | |
Workbook wb = new Workbook(); | |
//Access system defined document property collection. | |
Aspose.Cells.Properties.BuiltInDocumentPropertyCollection sdmd = wb.BuiltInDocumentProperties; | |
//Set the language of the Excel document. | |
sdmd.Language = "German, French"; | |
//Save the workbook in xlsx format. | |
wb.Save(outputDir + "system-defined-properties-updated.xlsx", SaveFormat.Xlsx); |
إدارة الخصائص المحددة المخصصة
لإدارة الخصائص المحددة من قبل المستخدم، يوفر API خصائص المستند المخصص ويمكن للمطورين الوصول بسهولة إلى الخصائص المضافة بالفعل بالإضافة إلى إضافة خصائص جديدة. ولإضافة خصائص مخصصة، أضف طريقة ل CustomDocumentPropertyCollection تضيف الفئة الخاصية وترجع مرجعًا للخاصية الجديدة باعتبارها خصائص.DocumentProperty هدف. يتم استخدام فئة DocumentProperty لاسترداد اسم وقيمة ونوع خاصية المستند كـ DocumentProperty.Name , DocumentProperty.Value , DocumentProperty.Type التي ترجع واحدة من نوع الملكية قيم التعداد.
C# كود اضافة البيانات الوصفية في ملف الاكسل
// string dataDir = "he path to the documents directory." | |
// Instantiate a Workbook object | |
// Open an Excel file | |
Workbook wkb = new Workbook(dataDir + "sample-document-properties.xlsx"); | |
// Retrieve a list of all custom document properties of the Excel file | |
Aspose.Cells.Properties.CustomDocumentPropertyCollection customProperties = wkb.Worksheets.CustomDocumentProperties; | |
// Adding a custom document property to the Excel file | |
Aspose.Cells.Properties.DocumentProperty publisher = customProperties.Add("Publisher", "Aspose"); | |
// Add link to content. | |
customProperties.AddLinkToContent("Owner", "MyRange"); | |
// way to access custom property by using the property name | |
Aspose.Cells.Properties.DocumentProperty customProperty1 = customProperties["Owner"]; | |
// Saving resultant spreadsheet | |
wkb.Save(dataDir + "out_sample-document-properties.xlsx"); |
C# كود إزالة الخاصية المخصصة في ملف إكسل
//string dataDir = "The path to the documents directory"; | |
// Instantiate a Workbook object | |
// Open an Excel file | |
Workbook wkb = new Workbook(dataDir + "sample-document-properties.xlsx"); | |
// Retrieve a list of all custom document properties of the Excel file | |
Aspose.Cells.Properties.DocumentPropertyCollection customProperties = wkb.Worksheets.CustomDocumentProperties; | |
// Removing a custom document property | |
customProperties.Remove("Publisher"); | |
// Save the file | |
wkb.Save(dataDir + "out_sample-document-properties.xlsx"); |