استبدال النص في دفتر العمل باستخدام التعبير العادي
Contents
[
Hide
]
توفر Aspose.Cells ميزة استبدال النص في دفتر العمل باستخدام تعبير عادي. لهذا الغرض، يوفر الـ API خاصية RegexKey لفئة ReplaceOptions. تعيين RegexKey إلى true يشير إلى أن المفتاح المبحث سيكون تعبيرًا عاديًا.
يوضح مقتطف الكود التالي استخدام خاصية RegexKey باستخدام ملف إكسل عيني. يتم إرفاق ملف الإخراج الذي تم إنشاؤه بواسطة مقتطف الكود التالي للإشارة.
الكود المثالي
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |