Home

Bytescout.XLS for .NET
Screenshots

Click to view sample
Click to view sample
Click to view sample
Click to view sample
Click to view sample
Click to view sample
Click to view sample Click to view sample

Bytescout.XLS library for .NET

Download Free Trial Buy Now More Information

How to validate data in existing Excel XLS spreadsheet and mark incorrect values with color using Bytescout.XLS library

This source code sample demonstrates how to open existing Excel document (XLS) and check cell values if cells contains correct values or not. Then mark incorrect values with red color and save spreadsheet file

Download example source code: bytescoutxls_validate_cells_mark_wrong_with_color.zip (8 KB)

Validated document screenshot (incorrect value is now marked with red color background):

Validated document with incorrect value marked with red color background

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Bytescout.XLS;

namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
// Create new XLSDocument
XLSDocument document = new XLSDocument("Data.xls");

// 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.XLS.Constants.PatternStyle.Solid;

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

// Save document
document.SaveAs("CheckedData.xls");

// Close document
document.Close();

// open generated XLS document in default program
Process.Start("CheckedData.xls");
}
}
}

Download example source code: bytescoutxls_validate_cells_mark_wrong_with_color.zip (8 KB)

Download Free Trial Buy Now More Information

Documentation online: view (separate window)

First steps tutorials:

Advanced Examples:
Products  |  Download  |  Purchase  |  Support  |  Contacts  |  Testimonials |  

ByteScout, 2003-2008. All other company and product names may be trademarks of their respective companies. Privacy Statement