التلاعب في النطاق المسمى في سجل عمل

سيناريوهات الاستخدام المحتملة

Aspose.Cells يدعم التلاعب بالنطاقات المسماة الموجودة. يمكن الوصول إلى جميع النطاقات المسماة الموجودة من مجموعة Workbook.GetWorksheets().GetNames(). بمجرد أن يتم الوصول إلى النطاق المسمى، يمكنك تغيير طرقه المختلفة مثل GetFullText و GetRefersTo على سبيل المثال.

التلاعب في النطاق المسمى في سجل عمل

الكود العينة التالي يقرأ اول نطاق مسمى داخل ملف إكسل المصدر ويطبع نص كامل و يشير الى الخصائص على الكونسول. بعد ذلك، يعدل خاصية يشير الى ويحفظ ملف إكسل الناتج.

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

Aspose::Cells::Startup();
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
//Path of input
U16String dirPath(u"");
//Path of output
U16String outPath(u"");
//Path of input excel file
U16String sampleManipulateNamedRangeInWorkbook = dirPath + u"sampleManipulateNamedRangeInWorkbook.xlsx";
//Path of output excel file
U16String outputManipulateNamedRangeInWorkbook = outPath + u"outputManipulateNamedRangeInWorkbook.xlsx";
//Create a workbook
Workbook wb(sampleManipulateNamedRangeInWorkbook);
//Read the named range created above from names collection
Name nm = wb.GetWorksheets().GetNames().Get(0);
//Print its FullText and RefersTo members
std::cout << "Full Text : " << nm.GetFullText().ToUtf8() << std::endl;
std::cout << "Refers To : " << nm.GetRefersTo().ToUtf8() << std::endl;
//Manipulate the RefersTo property of NamedRange
nm.SetRefersTo(u"=Sheet1!$D$5:$J$10");
//Save the workbook in xlsx format
wb.Save(outputManipulateNamedRangeInWorkbook, SaveFormat::Xlsx);
Aspose::Cells::Cleanup()

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

الناتج الخاص بالكونسول يطبع قيم نص كامل و يشير الى لأعضاء النطاق المسمى الحالي في الكود أعلاه.

 Full Text: TestRange

Refers To: =Sheet1!$D$3:$G$6