Last active
April 27, 2021 12:03
-
-
Save aspose-com-gists/20bea3a300043930ddaff689d1629fd5 to your computer and use it in GitHub Desktop.
Find and Replace Text in Excel Spreadsheets using C++
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
Find and Replace Text in Excel Spreadsheets using C++ |
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
// Source directory path. | |
StringPtr srcDir = new String("SourceDirectory\\"); | |
// Output directory path. | |
StringPtr outDir = new String("OutputDirectory\\"); | |
// Load Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(srcDir->StringAppend(new String("book1.xlsx"))); | |
// Create an instance of the IReplaceOptions class | |
intrusive_ptr<IReplaceOptions> replaceOptions = Factory::CreateIReplaceOptions(); | |
// Set case sensitivity option | |
replaceOptions->SetCaseSensitive(false); | |
// Set text matching option | |
replaceOptions->SetMatchEntireCellContents(false); | |
// Replace text | |
workbook->Replace(new String("Text to find"), new String("Text replacement"), replaceOptions); | |
// Save as Excel file | |
workbook->Save(outDir->StringAppend(new String("book1_out.xlsx"))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment