We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Range.Replace equalent in Aspose.cells


what is the "Range.Replace" equalent in Aspose.cell.That is i have a variable in Excel and i need to replace that variable with some value.In Aspose.Word i have used "Range.Replace" and i need the equalent in Aspose.cell


Thanks for your posting and using Aspose.Cells for .NET.

From your description, I think, Smart Marker features will fullfill your needs.

You put smart marker tags in an input file then these tags are replaced with actual values that are present in your database/datatables.

Please see this article for your more help.

Smart Markers


Well, if you need to simply find and replace options to replace some value with other value in a worksheet or workbook, we provide Worksheet.Replace() and Workbook.Replace() methods to replace the values in a worksheet or even in the whole workbook, see the sample code below:

Sample code:

Workbook wb = new Workbook(“e:\test\casesensitive\test.xls”);
ReplaceOptions replace = new ReplaceOptions();
replace.CaseSensitive = false;
replace.MatchEntireCellContents = false;
wb.Replace(“officialName”, “mmAwesome Agency”,replace);

Moreover, you may try to find your desired value in a cell area using FindXXXX methods of Cells class, you may easily replace your found cell’s values with your desired values using String.Replace() method accordingly.
See the document for reference here.
Also, see another sample code for your reference for finding and replacing a value using FindXXX method of Cells class:

Sample code:

Workbook workbook = new Workbook(@"e:\test\FindStringContains1.xls");
WorksheetCollection worksheets = workbook.Worksheets;
string stringtofind = "Test";
string stringtoreplace = "Rock";
for (int i = 0; i < worksheets.Count; i++)

Worksheet worksheet = workbook.Worksheets[i];
Cells cells = worksheet.Cells;
Cell cell;
Cell prevcell = null;

cell = cells.FindStringContains(stringtofind, prevcell);
if (cell == null)
string val = cell.StringValue.Replace(stringtofind, stringtoreplace);
prevcell = cell;

} while (cell != null);


Thank you.

I want to repleace a character (for excaple “a”) with another character (“b”) in a whole worksheet…
above code replace the value of a cell completely … I just want to replace a character not whole the cells…
which code I should use?
thanks a lot

You may use following sample code and share the feedback.

Workbook wb = new Workbook(@"book1.xlsx");
Worksheet ws = wb.Worksheets[0];
ws.Replace("a", "b");