1. Home
  2.   Cells
  3.   Openize.Cells for .NET
Openize.Cells for .NET

Openize.Cells for .NET


Streamline Excel Spreadsheet Generation and Customization with .NET API

Easily generate and customize spreadsheets using Openize.Cells, an Open-Source .NET API. Simplify workbook creation and automation with this lightweight library.

Openize.Cells for .NET provides a simple, intuitive, and user-friendly experience, making it the perfect solution for those working with Microsoft Excel spreadsheets through an open-source API. This .NET API has been meticulously crafted to streamline the creation and customization of Excel spreadsheets. With this intuitive C# library, generating and manipulating spreadsheets is now effortlessly achievable with just a few lines of code.

The installation of this lightweight solution is seamless and offers a wealth of features to meet all your spreadsheet needs. Openize.Cells for .NET leverages the power of the OpenXML SDK, a technology endorsed by Microsoft. Serving as a convenient wrapper, Openize.Cells for .NET simplifies the utilization of its advanced capabilities.

Designed with developers in mind, this Open-Source .NET library empowers you to automate the creation and editing of Excel Spreadsheets with ease. Extend its capabilities by leveraging the OpenXML SDK library. Managing Openize.Cells for .NET is straightforward, thanks to its user-friendly design. The library boasts a range of intelligent features, including adding sheets, text, opening existing spreadsheets in stream, applying formatting to the entire workbook or specific cells, adding images to the spreadsheets, and much more.

Explore our GitHub repository to contribute, suggest improvements, and enhance this Open Source API: https://github.com/fileformat-cells/Openize.Cells-for-.NET

Previous Next

Getting Started with Openize.Cells for .NET

The recommended way to install Openize.Cells for .NET is using NuGet. Please use the following command for a smooth installation.

Install Openize.Cells for .NET via NuGet

NuGet\Install-Package Openize.Cells 
You can also download it directly from GitHub.

Creating an Empty Excel Workbook / Spreadsheet Programmatically

The following code snippet exemplifies how to create and save a new Microsoft Excel spreadsheet using C# with the Openize.Cells library.

  • The code begins by importing the necessary library Openize.Cells, providing access to functionalities for Excel spreadsheet manipulation.
  • Within the Example namespace, the Program class is defined.
  • The Main method serves as the entry point of the program, accepting command-line arguments if any (string[] args).
  • An instance of the Workbook class is initialized using Workbook workbook = new Workbook();.
  • The Save method is invoked on the workbook instance to save the Excel spreadsheet. The file is saved with the name "Spreadsheet.xlsx" in the root directory `("/") of the disk.

Copy and paste the code snippet below into your main file and execute the program.

Create an Empty Workbook / Spreadsheet in C#

using Openize.Cells;

namespace Example
    class Program
        static void Main(string[] args)
            // Initialize an instance of the Workbook class.
            Workbook workbook = new Workbook();

            // Call the Save method to save the MS Excel Spreadsheet/Workbook onto the disk.


Getting Cell Values from an Excel Spreadsheet/ Workbook Programmatically

The following code illustrates how to open an existing Microsoft Excel spreadsheet using C# and retrieve the value from a specific cell. To access and interact with your spreadsheet, follow these steps:

  • Create an instance of the Workbook class by specifying the path to your existing spreadsheet.
  • Retrieve the Worksheet from the Workbook.
  • Assign the cell object to a variable.
  • Use the GetValue() method to extract the value from the specified cell.

Copy and paste the code snippet below into your main file and execute the program.

Getting Cell Values from a Workbook in C#


using (Workbook wb = new Workbook(filePath)) // Load existing spreadsheet/workbook file.
    Worksheet firstSheet = wb.Worksheets[0]; // Load first worksheet within workbook.
    Cell cellA1 = firstSheet.Cells["A1"]; // Get A1 cell object within cellA1 variable.
    Console.WriteLine(cellA1.GetDataType()); // Output cellA1 data type.
    string value = cellA1.GetValue(); // Get value within cell A1.
    Console.WriteLine(value); // Output the value stored in cell A1

Merging Cells within an Excel Worksheet Programatically

The provided code demonstrates how to programmatically merge cells in a Microsoft Excel spreadsheet using C#. Here's a breakdown of the steps:

  • Initialize a new instance of the Workbook class.
  • Access the first worksheet within the workbook.
  • Utilize the MergeCells method to merge cells from A1 to C1.
  • Assign a value to the top-left cell of the merged area..
  • Save the modified workbook to a specified file path.

To integrate this functionality into your C# application, follow these steps:

  • Insert the code snippet into your main file.
  • Execute the program to merge cells and assign values accordingly.

This approach streamlines the process of merging cells and manipulating cell data within Excel spreadsheets programmatically

Copy and paste the code snippet below into your main file and execute the program.

Code snippet to merge cells within a worksheet


using (var workbook = new Workbook())
    var firstSheet = workbook.Worksheets[0];
    firstSheet.MergeCells("A1", "C1"); // Merge cells from A1 to C1

    // Add value to the top-left cell of the merged area
    var topLeftCell = firstSheet.Cells["A1"];
    topLeftCell.PutValue("This is a merged cell");