Skip to footer content
COMPARE TO OTHER COMPONENTS
A Comparison of NPOI vs IronXL

A Comparison of IronXL and NPOI

IronXL and NPOI are both .NET Excel libraries that work without Office.Interop — no Microsoft Excel installation required. This comparison covers their APIs for reading, writing, and manipulating Excel files, with code examples for the operations developers encounter most often.

What is NPOI?

NPOI is the .NET version of the POI Java project at http://poi.apache.org/. POI is an open-source project that can help you read/write xls, doc, ppt files. It has a wide range of applications.

For example, you can use it to:

  • Generate an Excel report without Microsoft Office suite installed on your server and more efficient than calling Microsoft Excel ActiveX in the background
  • Extract text from Office documents to help you implement a full-text indexing feature (most of the time this feature is used to create search engines)
  • Extract images from Office documents
  • Generate Excel sheets that contain formulas

NPOI and Excel

NPOI is a C# port of the POI Java project by Apache. It is free and open-source. Also, it doesn't need Interop, meaning that users will not need to have Excel installed to have the developer's app work with it.

IronXL and Excel

IronXL is an Excel API for VB and C#. With IronXL you can read, edit, and create Excel spreadsheet files in .NET.

How Do NPOI and IronXL Compare?

NPOI IronXL
Cell Ranges Cell Ranges
Cell styling (Border, Color, Fill, Font, Number, Alignments) Cell visual styles Font, Size, Background pattern, Border, Alignment, and Number formats.
Formula calculation Formulas
Data Validation Data Validation
Conditional formatting Conditional formatting
Images Images
Charts Charts

Table 1 - Feature Comparison

Teams evaluating IronXL as an NPOI alternative can test the full API with a free 30-day trial.


Installation of IronXL and NPOI

You can install both libraries by downloading them manually, via NuGet, or with the NuGet Package Manager in Visual Studio. Here is a quick overview; for a step-by-step walkthrough, see the IronXL getting started guide.

NPOI Installation

Installing NPOI with NuGet

To install NPOI through NuGet, open the Visual Studio developer command prompt and enter the following:

Install-Package NPOI -Version x.x.x
Graphical user interfaceDescription automatically generated

Figure 1 - NuGet NPOI Installation

Visual Studio NuGet Package Manager and NPOI

Use the following steps to install IronXL or NPOI via the NuGet Package Manager in Visual Studio:

  • Right-click the project in the Solution Explorer
  • Select Manage NuGet Packages
  • Browse for your Package
  • Click Install
A screenshot of a computerDescription automatically generated

Figure 2 - NuGet Package Manager for NPOI

IronXL Installation

Downloading IronXL

To download IronXL, navigate to the following URL and click the "Download" button.

Download IronXL

Figure 3 - Download IronXL

Installing IronXL with NuGet

To install IronXL through NuGet, open the Visual Studio developer command prompt and enter the following:

Install-Package IronXL.Excel -Version x.x.x
NuGet IronXL Installation

Figure 4 - NuGet IronXL Installation

Visual Studio NuGet Package Manager and IronXL

Use the following steps to install IronXL via the NuGet Package Manager in Visual Studio:

  • Right-click the project in the Solution Explorer
  • Select Manage NuGet Packages
  • Browse for your Package
  • Click Install
A screenshot of a computerDescription automatically generated

Figure 5 - NuGet Package Manager for IronXL

Reading from and writing to an Excel file with NPOI and IronXL

Reading an Excel file with NPOI

The following code demonstrates how to read an Excel file and display its contents with NPOI. Add the following code and include the necessary namespaces:

using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System.Data;
using System.IO;
using System.Collections.Generic;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System.Data;
using System.IO;
using System.Collections.Generic;
$vbLabelText   $csharpLabel

The below code reads an existing Excel file and displays it inside a data grid view.

public void ReadExcelNPOI()
{
    DataTable dtTable = new DataTable();
    List<string> lstRows = new List<string>();
    ISheet objWorksheet;
    string strPath = @"c:\temp\NPOI_Test.XLSX";

    // Use FileStream to open the Excel file
    using (var fStream = new FileStream(strPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
    {
        fStream.Position = 0;
        XSSFWorkbook objWorkbook = new XSSFWorkbook(fStream);
        objWorksheet = objWorkbook.GetSheetAt(0);
        IRow objHeader = objWorksheet.GetRow(0);
        int countCells = objHeader.LastCellNum;

        // Add columns to the DataTable based on the header row of Excel
        for (int j = 0; j < countCells; j++)
        {
            ICell objCell = objHeader.GetCell(j);
            if (objCell == null || string.IsNullOrWhiteSpace(objCell.ToString())) continue;
            {
                dtTable.Columns.Add(objCell.ToString());
            }
        }

        // Add rows to the DataTable, looping through each row and cell
        for (int i = (objWorksheet.FirstRowNum + 1); i <= objWorksheet.LastRowNum; i++)
        {
            IRow objRow = objWorksheet.GetRow(i);
            if (objRow == null || objRow.Cells.All(d => d.CellType == CellType.Blank)) continue;

            for (int j = objRow.FirstCellNum; j < countCells; j++)
            {
                ICell cell = objRow.GetCell(j);
                if (cell != null && !string.IsNullOrEmpty(cell.ToString()) && !string.IsNullOrWhiteSpace(cell.ToString()))
                {
                    lstRows.Add(cell.ToString());
                }
            }

            if (lstRows.Count > 0)
                dtTable.Rows.Add(lstRows.ToArray());

            lstRows.Clear();
        }
    }

    // Assuming dataGridView1 is a DataGridView control on a Form
    dataGridView1.DataSource = dtTable;
}

private void button1_Click(object sender, EventArgs e)
{
    ReadExcelNPOI();
}
public void ReadExcelNPOI()
{
    DataTable dtTable = new DataTable();
    List<string> lstRows = new List<string>();
    ISheet objWorksheet;
    string strPath = @"c:\temp\NPOI_Test.XLSX";

    // Use FileStream to open the Excel file
    using (var fStream = new FileStream(strPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
    {
        fStream.Position = 0;
        XSSFWorkbook objWorkbook = new XSSFWorkbook(fStream);
        objWorksheet = objWorkbook.GetSheetAt(0);
        IRow objHeader = objWorksheet.GetRow(0);
        int countCells = objHeader.LastCellNum;

        // Add columns to the DataTable based on the header row of Excel
        for (int j = 0; j < countCells; j++)
        {
            ICell objCell = objHeader.GetCell(j);
            if (objCell == null || string.IsNullOrWhiteSpace(objCell.ToString())) continue;
            {
                dtTable.Columns.Add(objCell.ToString());
            }
        }

        // Add rows to the DataTable, looping through each row and cell
        for (int i = (objWorksheet.FirstRowNum + 1); i <= objWorksheet.LastRowNum; i++)
        {
            IRow objRow = objWorksheet.GetRow(i);
            if (objRow == null || objRow.Cells.All(d => d.CellType == CellType.Blank)) continue;

            for (int j = objRow.FirstCellNum; j < countCells; j++)
            {
                ICell cell = objRow.GetCell(j);
                if (cell != null && !string.IsNullOrEmpty(cell.ToString()) && !string.IsNullOrWhiteSpace(cell.ToString()))
                {
                    lstRows.Add(cell.ToString());
                }
            }

            if (lstRows.Count > 0)
                dtTable.Rows.Add(lstRows.ToArray());

            lstRows.Clear();
        }
    }

    // Assuming dataGridView1 is a DataGridView control on a Form
    dataGridView1.DataSource = dtTable;
}

private void button1_Click(object sender, EventArgs e)
{
    ReadExcelNPOI();
}
$vbLabelText   $csharpLabel

Reading an Excel file with IronXL

The following code demonstrates how to read an Excel file and display it inside a data grid view with IronXL. For more IronXL code examples, see the documentation. Add the following code and include the namespace:

using IronXL;
using System.Data;
using IronXL;
using System.Data;
$vbLabelText   $csharpLabel

Notice the inclusion of IronXL. This is necessary for IronXL to work. Add the next few lines:

private void button2_Click(object sender, EventArgs e)
{
    // Load the Excel workbook
    string strPath = @"c:\temp\NPOI_Test.XLSX";
    WorkBook workbook = WorkBook.Load(strPath);

    // Access the default worksheet
    WorkSheet sheet = workbook.DefaultWorkSheet;

    // Convert the worksheet to a DataTable
    var dtTable = sheet.ToDataTable(true);

    // Assuming dataGridView1 is a DataGridView control on a Form
    dataGridView1.DataSource = dtTable;
}
private void button2_Click(object sender, EventArgs e)
{
    // Load the Excel workbook
    string strPath = @"c:\temp\NPOI_Test.XLSX";
    WorkBook workbook = WorkBook.Load(strPath);

    // Access the default worksheet
    WorkSheet sheet = workbook.DefaultWorkSheet;

    // Convert the worksheet to a DataTable
    var dtTable = sheet.ToDataTable(true);

    // Assuming dataGridView1 is a DataGridView control on a Form
    dataGridView1.DataSource = dtTable;
}
$vbLabelText   $csharpLabel

As you can see, IronXL reduces the read-and-display operation to roughly 5 lines of code compared to NPOI's 40+, eliminating the manual row iteration and cell-by-cell extraction loop entirely. Browse the full set of IronXL feature guides for more streamlined approaches to common Excel tasks.

Which Library Should You Choose?

NPOI provides a solid, well-established open-source foundation for Excel manipulation in .NET — its heritage as a port of Apache POI means it benefits from years of community contributions and broad format coverage. For teams whose primary requirement is reading and writing spreadsheets in a free, community-driven package, NPOI is a dependable choice.

Where teams often hit friction is in the amount of boilerplate code NPOI requires for common operations. As the read-file example above illustrates, IronXL’s approach requires roughly 5 lines of code versus NPOI’s 40+ lines for the same operation — loading a workbook and displaying it in a data grid — eliminating the manual row-and-cell iteration loop entirely. That reduction in code surface area is an investment that pays off through easier maintenance and fewer places for bugs to hide.

IronXL also includes professional support, consistent update schedules, and the ability to request features directly from Iron Software engineers. Community-driven projects offer different trade-offs in this regard: broader contributor input, but less predictable response times for specific issues.

Beyond license cost, total project cost includes the developer hours spent writing and maintaining the additional boilerplate that NPOI’s lower-level API requires, as well as debugging the manual data-mapping logic shown in the examples above. For teams evaluating cost over a multi-year project lifecycle, these development and maintenance costs frequently eclipse the difference between open-source and commercial licensing.

Downloads

This project is available on GitHub:

IronXL vs NPOI Example

Ready to see the difference in your own project? Start a free 30-day IronXL trial to run these examples locally.

Please noteNPOI is a registered trademark of its respective owner. This site is not affiliated with, endorsed by, or sponsored by NPOI. All product names, logos, and brands are property of their respective owners. Comparisons are for informational purposes only and reflect publicly available information at the time of writing.

Frequently Asked Questions

What is an alternative to using Office.Interop for Excel manipulation in C#?

IronXL is an alternative to using Office.Interop for Excel manipulation in C#. It provides a user-friendly API that allows developers to create, read, and edit Excel files without needing Microsoft Office installed.

How can I convert Excel files to PDF in C#?

You can use IronXL to convert Excel files to PDF in C# by loading the Excel workbook with WorkBook.Load and then using the WorkBook.SaveAs method to save the file in PDF format.

What are the key benefits of using IronXL for Excel file manipulation?

IronXL offers a more intuitive API for easier code maintenance, professional support, regular updates, and the ability to handle Excel files without Microsoft Office installed, which makes it a strong choice for developers.

Can IronXL be installed via NuGet?

Yes, IronXL can be installed via NuGet. Open the Visual Studio developer command prompt and enter Install-Package IronXL.Excel -Version x.x.x.

What are some common Excel-related tasks that can be performed using IronXL?

Using IronXL, developers can perform tasks such as reading and writing Excel files, styling cells, using formulas, validating data, applying conditional formatting, and working with images and charts.

How do I read an Excel file in C# without Microsoft Office?

With IronXL, you can read an Excel file in C# by loading the workbook using WorkBook.Load, accessing the worksheet, and iterating through rows and cells using straightforward methods.

Why choose IronXL over open-source alternatives for Excel manipulation?

IronXL provides a more user-friendly API, professional support, regular updates, and ongoing feature requests, which are advantages over open-source alternatives like NPOI.

How does NPOI differ from IronXL for Excel file manipulation?

NPOI is an open-source library based on the Apache POI project for handling Excel files without Microsoft Office. IronXL, however, offers a more intuitive API, professional support, and regular updates, making it suitable for commercial applications.

What is the process for converting an Excel worksheet to a DataTable using IronXL?

To convert an Excel worksheet to a DataTable using IronXL, load the workbook with WorkBook.Load, access the desired worksheet, and use the available method to convert it to a DataTable for further use.

How can IronXL enhance Excel file management in .NET applications?

IronXL enhances Excel file management in .NET applications by offering a clean and intuitive API, facilitating tasks like reading, editing, and creating Excel files with ease, without relying on Microsoft Office installations.

Jordi Bardia
Software Engineer
Jordi is most proficient in Python, C# and C++, when he isn’t leveraging his skills at Iron Software; he’s game programming. Sharing responsibilities for product testing, product development and research, Jordi adds immense value to continual product improvement. The varied experience keeps him challenged and engaged, and he ...
Read More

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me