1. Products
  2.   Spreadsheet
  3.   .NET
  4.   FastExcel
 
  

Open Source .NET Library for Microsoft® Excel Spreadsheets

Provides Fast Excel XLSX Spreadsheet Reading, Writing, Editing, Converting, Merging & Manipulation via Free & Open Source .NET Library.

What is FastExcel?

FastExcel is a handy C# .NET library that lets you quickly read and write Excel XLSX spreadsheets. What’s great about this tool is that it doesn’t hog up much memory while it’s working. The secret? Well, it skips using the Open XML SDK altogether for its operations. Instead, it directly accesses and modifies the data from the XML files underneath.

Our goal with this project is to offer you a quick and efficient method to work with Excel data, providing you with basic Excel functions in a lightweight package. We’ve put a lot of work into speeding up the process, enabling .NET developers like you to seamlessly integrate key features into your applications. These features include tasks like reading and writing Excel files, accessing cell ranges, handling Excel tables, managing rows and columns, inserting text, adding images or new sheets, ensuring Excel file security, performing formula calculations, and much more.

The FastExcel library is designed to make it easy for software developers with various levels of expertise to work with Excel data. It provides a simple and intuitive interface for sorting, filtering, merging, viewing, and running advanced calculations on Excel files. This library is optimized to efficiently process data while keeping memory usage low. This means that even when working with large datasets, it runs smoothly and boosts performance.

Previous Next

Getting Started with FastExcel

The recommended way to install FastExcel is from NuGet. Use the following command for quick installation.

Install FastExcel  from NuGet

 Install-Package FastExcel -Version 3.0.6

Generate Spreadsheet Files via .NET API

FastExcel gives C# .NET programmers the competency to generate an Excel spreadsheet inside their own .NET applications. You can easily define how many rows and columns you want to keep inside the sheet. It also requires assigning a name to a sheet. Developers can set font type and text size for a created sheet. The following are the steps to generate and insert data in excel fastly.

Generate Excel Fastly

  1. Initialize object of FastExcel
  2. Create worksheet
  3. Populate row data
  4. Write Excel

How to Create Excel Files Quickly with Free Library via C# API?

using (FastExcel.FastExcel fastExcel = new FastExcel.FastExcel(new FileInfo("Template.xlsx"), new FileInfo("Output.xlsx")))
{
  //Create a worksheet with some rows
  var worksheet = new Worksheet();
  var rows = new List();
  for (int rowNumber = 1; rowNumber < 100000; rowNumber++)
  {
    List cells = new List();
    for (int columnNumber = 1; columnNumber < 13; columnNumber++)
    {
      cells.Add(new Cell(columnNumber, columnNumber * DateTime.Now.Millisecond));
    }
    cells.Add(new Cell(13, "FileFormat" + rowNumber));
    cells.Add(new Cell(14, "FileFormat Developer Guide"));

    rows.Add(new Row(rowNumber, cells));
  }
  worksheet.Rows = rows;

  fastExcel.Write(worksheet, "sheet1");
}

Rows and Cell Management in Excel Worksheet

The open source .NET API FastExcel supports features for managing cells and rows inside Excel spreadsheets. It allows developers to create new rows, merge a row to the next row, get all cells in this row, create a new cell, select a range of cells, select value from a cell, the worksheet that this cell is on, and many more.

How to Read Cells from Excel Files via Free .NET Library via C#?

// Create an instance of Fast Excel
using (FastExcel.FastExcel fastExcel = new FastExcel.FastExcel(new FileInfo("input.xlsx")))
{
  //Create a some rows in a worksheet
  var worksheet = new Worksheet();
  var rows = new List();

  for (int rowNumber = 1; rowNumber < 100000; rowNumber += 50)
  {
    List cells = new List();
    for (int columnNumber = 1; columnNumber < 13; columnNumber += 2)
    {
      cells.Add(new Cell(columnNumber, rowNumber));
    }
    cells.Add(new Cell(13, "File Format Developer Guide"));

    rows.Add(new Row(rowNumber, cells));
  }
  worksheet.Rows = rows;
  // Read the data
  fastExcel.Update(worksheet, "sheet1");
}

Worksheet Management in Excel Files

FastExcel allows to select & read a particlar worksheet using its index or all worksheets one by one using the iterator over the worksheet collection.

How to Read Particular Excel Worksheet with .NET Library via C# Library?

// Get the input file path
var inputFile = new FileInfo("C:\\Temp\\input.xlsx");

//Create a worksheet
Worksheet worksheet = null;

// Create an instance of Fast Excel
using (FastExcel.FastExcel fastExcel = new FastExcel.FastExcel(inputFile, true))
{
    // Read the rows using worksheet name
    worksheet = fastExcel.Read("sheet1");

    // Read the rows using the worksheet index
    // Worksheet indexes are start at 1 not 0
    worksheet = fastExcel.Read(1);
}

How to Read All Excel Worksheets with .NET Library via C#?

// Get the input file path
var inputFile = new FileInfo("C:\\Temp\\fileToRead.xlsx");

// Create an instance of Fast Excel
using (FastExcel.FastExcel fastExcel = new FastExcel.FastExcel(inputFile, true))
{
    foreach (var worksheet in fastExcel.Worksheets)
    {
        Console.WriteLine(string.Format("Worksheet Name:{0}, Index:{1}", worksheet.Name, worksheet.Index));
        
        //To read the rows call read
        worksheet.Read();
        var rows = worksheet.Rows.ToArray();
        //Do something with rows
        Console.WriteLine(string.Format("Worksheet Rows:{0}", rows.Count()));
    }
}

Comments Addition to Excel Cell

FastExcel API facilitates .NET developers to add and modify comments to Excel Cell. It is very beneficial to insert comments for reminders & notes for other subjects. The API supports features like adding a comment, moving the comment box, displaying or hide comments, deleting a comment, comment formatting, etc.

Apply Formatting to Cells using C#

The open source FastExcel library has included support for conditional formatting. Conditional formatting makes developers job easy to highlight certain values or enables them to automatically apply formatting to a particular spreadhseet cell coulmn or row.

 English