Node.js ve C++ kullanarak çalışma kitabındaki metni Regular Expression ile değiştirme
Contents
[
Hide
]
Aspose.Cells, çalışma kitabında metni düzenli ifadeyle değiştirme özelliği sunar. Bunun için API, ReplaceOptions sınıfının ReplaceOptions.getRegexKey() özelliğini sağlar. ReplaceOptions.getRegexKey() özelliğinin true olarak ayarlanması, aranacak anahtarın bir düzenli ifade olacağını gösterir.
Aşağıdaki kod parçacığı, örnek Excel dosyası kullanılarak ReplaceOptions.getRegexKey() özelliğinin kullanımını gösterir. Aşağıdaki kod parçası tarafından oluşturulan çıktı dosyası referans olması için eklenmiştir.
Örnek Kod
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// Source directory
const sourceDir = path.join(__dirname, "data");
// Output directory
const outputDir = path.join(__dirname, "output");
const filePath = path.join(sourceDir, "SampleRegexReplace.xlsx");
const workbook = new AsposeCells.Workbook(filePath);
const replace = new AsposeCells.ReplaceOptions();
replace.setCaseSensitive(false);
replace.setMatchEntireCellContents(false);
// Set to true to indicate that the searched key is regex
replace.setRegexKey(true);
workbook.replace("\\bKIM\\b", "^^^TIM^^^", replace);
workbook.save(path.join(outputDir, "RegexReplace_out.xlsx"));