//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; // Prepare data const string CorrectWord = "Macro"; worksheet.Range["A1:D5"].Value = CorrectWord; const string MisspelledWord = "marco"; worksheet.Range["A2,C3,D1"].Value = MisspelledWord; // Find all misspelled words and mark them with red background IRange searchRange = worksheet.Range["A1:D5"]; IRange misspelledCell = null; do { misspelledCell = searchRange.Find(MisspelledWord, misspelledCell); if (misspelledCell == null) { break; } misspelledCell.Interior.Color = System.Drawing.Color.Red; } while (true); // Save to an excel file workbook.Save("FindWithAfter.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) ' Prepare data Const CorrectWord = "Macro" worksheet.Range("A1:D5").Value = CorrectWord Const MisspelledWord = "marco" worksheet.Range("A2,C3,D1").Value = MisspelledWord ' Find all misspelled words and mark them with red background Dim searchRange As IRange = worksheet.Range("A1:D5") Dim misspelledCell As IRange = Nothing Do misspelledCell = searchRange.Find(MisspelledWord, misspelledCell) If misspelledCell Is Nothing Then Exit Do End If misspelledCell.Interior.Color = System.Drawing.Color.Red Loop ' save to an excel file workbook.Save("FindWithAfter.xlsx")