استبدال النص في دفتر العمل باستخدام التعبير العادي

توفر Aspose.Cells ميزة استبدال النص في دفتر العمل باستخدام تعبير عادي. لهذا الغرض، يوفر الـ API خاصية RegexKey لفئة ReplaceOptions. تعيين RegexKey إلى true يشير إلى أن المفتاح المبحث سيكون تعبيرًا عاديًا.

يوضح مقتطف الكود التالي استخدام خاصية RegexKey باستخدام ملف إكسل عيني. يتم إرفاق ملف الإخراج الذي تم إنشاؤه بواسطة مقتطف الكود التالي للإشارة.

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

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Source directory
string sourceDir = RunExamples.Get_SourceDirectory();
//Output directory
string outputDir = RunExamples.Get_OutputDirectory();
Workbook workbook = new Workbook(sourceDir + "SampleRegexReplace.xlsx");
ReplaceOptions replace = new ReplaceOptions();
replace.CaseSensitive = false;
replace.MatchEntireCellContents = false;
// Set to true to indicate that the searched key is regex
replace.RegexKey = true;
workbook.Replace("\\bKIM\\b", "^^^TIM^^^", replace);
workbook.Save(outputDir + "RegexReplace_out.xlsx");