ExcelizeCs 0.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package ExcelizeCs --version 0.0.1
                    
NuGet\Install-Package ExcelizeCs -Version 0.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ExcelizeCs" Version="0.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ExcelizeCs" Version="0.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ExcelizeCs" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ExcelizeCs --version 0.0.1
                    
#r "nuget: ExcelizeCs, 0.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ExcelizeCs@0.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ExcelizeCs&version=0.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ExcelizeCs&version=0.0.1
                    
Install as a Cake Tool

excelize-cs

<p align="center"><img width="500" src="https://github.com/xuri/excelize-cs/raw/main/excelize-cs.svg" alt="excelize-cs logo"></p>

<p align="center"> <a href="https://www.nuget.org/packages/ExcelizeCs"><img src="https://img.shields.io/nuget/v/ExcelizeCs.svg" alt="NuGet version"></a> <a href="https://github.com/xuri/excelize-cs/actions/workflows/build.yml"><img src="https://github.com/xuri/excelize-cs/actions/workflows/build.yml/badge.svg" alt="Build Status"></a> <a href="https://codecov.io/gh/xuri/excelize-cs"><img src="https://codecov.io/gh/xuri/excelize-cs/branch/main/graph/badge.svg" alt="Code Coverage"></a> <a href="https://opensource.org/licenses/BSD-3-Clause"><img src="https://img.shields.io/badge/license-bsd-orange.svg" alt="Licenses"></a> <a href="https://www.paypal.com/paypalme/xuri"><img src="https://img.shields.io/badge/Donate-PayPal-green.svg" alt="Donate"></a> </p>

Package excelize-cs is a C# port of Go Excelize library, providing a set of functions that allow you to write and read from XLAM / XLSM / XLSX / XLTM / XLTX files. Supports reading and writing spreadsheet documents generated by Microsoft Excel™ 2007 and later. Supports complex components by high compatibility, and provided streaming API for generating or reading data from a worksheet with huge amounts of data. This library needs .NET version 6, C# version 10 or later. The full API docs can be found at docs reference.

Basic Usage

Installation

dotnet add package ExcelizeCs --version 0.0.1

Create spreadsheet

Here is a minimal example usage that will create spreadsheet file.

using ExcelizeCs;

class Program
{
    static void Main()
    {
        var f = Excelize.NewFile();
        try
        {
            // Create a new sheet.
            var index = f.NewSheet("Sheet2");
            // Set value of a cell.
            f.SetCellValue("Sheet2", "A1", "Hello world.");
            f.SetCellValue("Sheet1", "B2", 100);
            // Set active sheet of the workbook.
            f.SetActiveSheet(index);
            // Save spreadsheet by the given path.
            f.SaveAs("Book1.xlsx");
        }
        catch (RuntimeError err)
        {
            Console.WriteLine(err.Message);
        }
        finally
        {
            var err = f.Close();
            if (!string.IsNullOrEmpty(err))
                Console.WriteLine(err);
        }
    }
}

Reading spreadsheet

The following constitutes the bare to read a spreadsheet document.

using ExcelizeCs;

class Program
{
    static void Main()
    {
        ExcelizeCs.File? f;
        try
        {
            f = Excelize.OpenFile("Book1.xlsx");
        }
        catch (RuntimeError err)
        {
            Console.WriteLine(err.Message);
            return;
        }
        try
        {
            // Get value from cell by given worksheet name and cell reference.
            var cell = f.GetCellValue("Sheet1", "B2");
            Console.WriteLine(cell);
            // Get all the rows in the Sheet1.
            var rows = f.GetRows("Sheet1");
            foreach (var row in rows)
            {
                foreach (var c in row)
                {
                    Console.Write($"{c}\t");
                }
                Console.WriteLine();
            }
        }
        catch (RuntimeError err)
        {
            Console.WriteLine(err.Message);
        }
        finally
        {
            // Close the spreadsheet.
            var err = f.Close();
            if (!string.IsNullOrEmpty(err))
                Console.WriteLine(err);
        }
    }
}

Add chart to spreadsheet file

With Excelize chart generation and management is as easy as a few lines of code. You can build charts based on data in your worksheet or generate charts without any data in your worksheet at all.

<p align="center"><img width="650" src="https://github.com/xuri/excelize-cs/raw/main/chart.png" alt="Add chart to spreadsheet file by Excelie for C#"></p>

using ExcelizeCs;

class Program
{
    static void Main()
    {
        var f = Excelize.NewFile();
        var data = new List<List<object?>>
        {
            new() { null, "Apple", "Orange", "Pear" },
            new() { "Small", 2, 3, 3 },
            new() { "Normal", 5, 2, 4 },
            new() { "Large", 6, 7, 8 },
        };
        var text = "Fruit 3D Clustered Column Chart";
        try
        {
            foreach (var row in data)
            {
                f.SetSheetRow(
                    "Sheet1",
                    Excelize.CoordinatesToCellName(1, data.IndexOf(row) + 1),
                    row
                );
            }
            var chart = new Chart
            {
                Type = ChartType.Col3DClustered,
                Series = new ChartSeries[]
                {
                    new()
                    {
                        Name = "Sheet1!$A$2",
                        Categories = "Sheet1!$B$1:$D$1",
                        Values = "Sheet1!$B$2:$D$2",
                    },
                    new()
                    {
                        Name = "Sheet1!$A$3",
                        Categories = "Sheet1!$B$1:$D$1",
                        Values = "Sheet1!$B$3:$D$3",
                    },
                    new()
                    {
                        Name = "Sheet1!$A$4",
                        Categories = "Sheet1!$B$1:$D$1",
                        Values = "Sheet1!$B$4:$D$4",
                    },
                },
                Title = new RichTextRun[] { new() { Text = text } },
            };
            f.AddChart("Sheet1", "E1", chart);
            // Save spreadsheet by the given path.
            f.SaveAs("Book1.xlsx");
        }
        catch (RuntimeError err)
        {
            Console.WriteLine(err.Message);
        }
        finally
        {
            var err = f.Close();
            if (!string.IsNullOrEmpty(err))
                Console.WriteLine(err);
        }
    }
}

Add picture to spreadsheet file

using ExcelizeCs;

class Program
{
    static void Main()
    {
        ExcelizeCs.File? f;
        try
        {
            f = Excelize.OpenFile("Book1.xlsx");
        }
        catch (RuntimeError err)
        {
            Console.WriteLine(err.Message);
            return;
        }
        try
        {
            // Insert a picture.
            f.AddPicture("Sheet1", "A1", "image.png", null);
            // Insert a picture to worksheet with scaling.
            f.AddPicture(
                "Sheet1",
                "A1",
                "image.jpg",
                new GraphicOptions
                {
                    ScaleX = 0.1,
                    ScaleY = 0.1,
                }
            );
            // Insert a picture offset in the cell with printing support.
            f.AddPicture(
                "Sheet1",
                "A1",
                "image.jpg",
                new GraphicOptions
                {
                    PrintObject = true,
                    LockAspectRatio = false,
                    OffsetX = 15,
                    OffsetY = 10,
                    Locked = false,
                }
            );
            // Save the spreadsheet with the origin path.
            f.Save();
        }
        catch (RuntimeError err)
        {
            Console.WriteLine(err.Message);
        }
        finally
        {
            // Close the spreadsheet.
            var err = f.Close();
            if (!string.IsNullOrEmpty(err))
                Console.WriteLine(err);
        }
    }
}

Contributing

Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change.

Licenses

This program is under the terms of the BSD 3-Clause License. See https://opensource.org/licenses/BSD-3-Clause.

The Excel logo is a trademark of Microsoft Corporation. This artwork is an adaptation.

gopher.{ai,svg,png} was created by Takuya Ueda. Licensed under the Creative Commons 3.0 Attributions license.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.4 202 11/7/2025
0.0.3 209 11/5/2025
0.0.2 188 10/17/2025
0.0.1 322 9/19/2025