PNG JPG BMP TIFF CSV
Aspose.Cells  for .NET

Search CSV Formats in C#

Native and high performance CSV document search using server-side Aspose.Cells for .NET APIs, without the use of any software like Microsoft or Adobe PDF.

How to Search CSV File Using C#

In order to search CSV file, we’ll use

Aspose.Cells for .NET

API which is a feature-rich, powerful and easy to use document searching API for C# platform. Open

NuGet

package manager, search for Aspose.Cells and install. You may also use the following command from the Package Manager Console.

Command


PM> Install-Package Aspose.Cells

Steps to Search CSV Files in C#

A basic document search with

Aspose.Cells for .NET

APIs can be done with just few lines of code.

  • Load CSV file using Workbook class.
  • Get the cells in relevant sheet.
  • Search Numbers, Date and Text using Find method

System Requirements

Our APIs are supported on all major platforms and Operating Systems. Before executing the code below, please make sure that you have the following prerequisites on your system.

  • Microsoft Windows or a compatible OS with .NET Framework, .NET Core, Mono or Xamarin Platforms
  • Development environment like Microsoft Visual Studio
  • Add reference to the Aspose.Cells for .NET DLL in your project - Install from NuGet using the Download button above
 

Search CSV Files - C#

// searching cells containing specified string value or number
Workbook workbook = new Workbook("book1.csv");

// get cells collection
Cells cells = workbook.Worksheets[0].Cells;

FindOptions opts = new FindOptions();
opts.LookInType = LookInType.Values;
opts.LookAtType = LookAtType.EntireContent;

// find the cell with the input integer or double
Cell cell1 = cells.Find(205, null, opts);

if (cell1 != null){
    Console.WriteLine("Name of the cell containing the value: " + cell1.Name);
}else{
    Console.WriteLine("Record not found ");
}

// find the cell with the input string
Aspose.Cells.Cell cell2 = cells.Find("Items A", null, opts);

if (cell2 != null){
    Console.WriteLine("Name of the cell containing the value: " + cell2.Name);
}else{
    Console.WriteLine("Record not found ");
}

// find the cell containing with the input string
opts.LookAtType = LookAtType.Contains;
Cell cell3 = cells.Find("Data", null, opts);

if (cell3 != null){
    Console.WriteLine("Name of the cell containing the value: " + cell3.Name);
}else{
    Console.WriteLine("Record not found ");
}  
 
  • About Aspose.Cells for .NET API

    Aspose.Cells API can be used to create, edit, convert and render Microsoft Excel formats to different formats. Moreover, it can be used for comprehensive charting, scalable reporting and reliable calculations within software applications. Aspose.Cells is a standalone API and it does not require any software like Microsoft or OpenOffice.

    Online CSV Search Live Demos

    Other Supported Search Formats

    Using C#, one can also search other formats including.

    ODS (OpenDocument Spreadsheet File)
    TSV (Tab-Separated Values)
    TXT (Text Document)
    XLS (Excel Binary Format)
    XLSB (Binary Excel Workbook File)
    XLSM (Spreadsheet File)