إدارة خصائص المستند

سيتيح لك Aspose.Cells العمل مع الخصائص المضمنة والمخصصة للوثيقة. هذه هي واجهة Microsoft Excel لفتح خصائص الوثيقة فقط انقر فوق خصائص متقدمة كما هو موضح في لقطة الشاشة وقم بعرضها.

تسمح Aspose.Cells لك بالعمل مع خصائص المستند المدمجة والمخصصة. إليك واجهة Microsoft Excel لفتح هذه خصائص المستند. ما عليك سوى النقر فوق خصائص متقدمة كما هو موضح في هذا الملتقط الشاشة وعرضها.

todo:image_alt_text

إدارة خصائص الوثيقة

يحمل الكود عينة التالي ملف اكسل عينة ويقرأ الخصائص المضمنة للوثيقة مثل العنوان، الموضوع ومن ثم يقوم بتغييرهم. بعد ذلك يقوم أيضاً بقراءة خصائص الوثيقة المخصصة أي MyCustom1 وبعد ذلك يضيف خاصية وثيقة مخصصة جديدة أي MyCustom5 ويكتب ملف الإكسل الناتج. اللقطة الشاشية التالية تظهر تأثير الكود العينة على ملف الإكسل العينة.

todo:image_alt_text

الكود المثالي

Aspose::Cells::Startup();
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
//Source directory path
U16String dirPath(u"..\\Data\\LoadingSavingAndConverting\\");
//Output directory path
U16String outPath(u"..\\Data\\Output\\");
//Paths of source and output excel files
U16String samplePath(dirPath + u"sampleManagingDocumentProperties.xlsx");
U16String outputPath(outPath + u"outputManagingDocumentProperties.xlsx");
//Load the sample excel file
Workbook wb(samplePath);
//Read built-in title and subject properties
U16String strTitle = wb.GetBuiltInDocumentProperties().GetTitle();
U16String strSubject = wb.GetBuiltInDocumentProperties().GetSubject();
U16String title(u"Title: ");
std::cout << title.ToUtf8() << strTitle.ToUtf8() << std::endl;
U16String subject(u"Subject: ");
std::cout << subject.ToUtf8()<<strSubject.ToUtf8() << std::endl;
//Modify built-in title and subject properties
strTitle = u"Aspose.Cells New Title";
strSubject = u"Aspose.Cells New Subject";
wb.GetBuiltInDocumentProperties().SetTitle(strTitle);
wb.GetBuiltInDocumentProperties().SetSubject(strSubject);
//Read the custom property
U16String strCustomPropName(u"MyCustom1");
U16String strCustomPropValue = wb.GetCustomDocumentProperties().Get(strCustomPropName).ToString();
U16String myCustom1(u"\r\nMyCustom1: ");
std::cout << myCustom1.ToUtf8()<<strCustomPropValue.ToUtf8() << std::endl;
//Add a new custom property
strCustomPropName = u"MyCustom5";
strCustomPropValue = u"This is my custom five.";
wb.GetCustomDocumentProperties().Add(strCustomPropName, strCustomPropValue);
//Save the output excel file
wb.Save(outputPath);
Aspose::Cells::Cleanup();

مخرجات الوحدة

هذه هي مخرجات الكونسول للكود العينة أعلاه عند تنفيذه مع ملف الإكسل العينة المقدم.

 Title: Aspose Team

Subject: Aspose.Cells for C++

MyCustom1: This is my custom one.