Free Support Forum - aspose.com

Replace Hypen words

How can i replace hyphen between words in aspose.cells.
Any example in .net?

@umakanth91

Please spare us some time, we will look into your issue and help you asap.

@umakanth91,

Thanks for your query and we are sorry for a delayed response. You may please give a try to the following sample code and provide your feedback.

string TXBX_Find = "-";
string TXBX_Replace = "*";
Workbook workbook = new Workbook(path + "book1.xlsx");
FindOptions Opts = new FindOptions();
Opts.LookInType = LookInType.Values;
Opts.LookAtType = LookAtType.Contains;
string found = "";
Aspose.Cells.Cell cell = null;
foreach (Worksheet sheet in workbook.Worksheets)
{
    do
    {
        cell = sheet.Cells.Find(TXBX_Find, cell, Opts);
        if (cell != null)
        {
            string celltext = cell.Value.ToString();
            celltext = celltext.Replace(TXBX_Find, TXBX_Replace);
            cell.PutValue(celltext);
        }
    }
    while (cell != null);
}
workbook.Save(path + "book2.xlsx");

Book1.zip (6.7 KB)
book2.zip (7.7 KB)