Link Search Menu Expand Document

Validate Data in Cell and Mark Wrong With Color - C#

Spreadsheet SDK sample in C# demonstrating ‘Validate Data in Cell and Mark Wrong With Color’

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Bytescout.Spreadsheet;
using System.IO;

namespace HelloWorld
    class Program
        static void Main(string[] args)
            // Create new Spreadsheet
            Spreadsheet document = new Spreadsheet();

            // Get worksheet by name
            Worksheet worksheet = document.Workbook.Worksheets.ByName("Sample");

            // Spellcheck words
            for (int i = 0; i < 5; i++)
                // Set current cell
                Cell currentCell = worksheet.Cell(0, i);

                // Spellcheck current cell
                if ((string)currentCell.Value == "Simpsan")
                    // Set fill pattern
                    currentCell.FillPattern = Bytescout.Spreadsheet.Constants.PatternStyle.Solid;

                    // Markup wrong word by red color
                    currentCell.FillPatternForeColor = System.Drawing.Color.Red;

            // delete output file if exists already
            if (File.Exists("Output.xls")){

            // Save document

            // Close Spreadsheet

            // open generated XLS document in default program


Download Source Code (.zip)

Return to the previous page Explore Spreadsheet SDK