usmanazizgroupdocs
7/5/2017 - 6:25 AM

RemoveTextShapesWithParticularTextFormattingExcel.cs

// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
using (CellsDocument doc = Document.Load<CellsDocument>(Utilities.MapSourceFilePath(FilePath)))
{
    foreach (CellsWorksheet section in doc.Worksheets)
    {
        for (var i = section.Shapes.Count - 1; i >= 0; i--)
        {
            foreach (var fragment in section.Shapes[i].FormattedTextFragments)
            {
                if (fragment.ForegroundColor == Color.Red && fragment.Font.FamilyName == "Arial")
                {
                    section.Shapes.RemoveAt(i);
                    break;
                }
            }
        }
    }
    doc.Save();
}