Skip to content

aydinthedev/mapexcel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MapExcel

MapExcel is a lightweight and easy-to-use library for mapping Excel files to C# objects. This library simplifies the process of reading from and writing to Excel files in your C# applications.

Quick Start

Usage

Defining a Model

public class Foo
{
    public string Name { get; set; }

    public DateTime Created { get; set; }
}

// Call this method in your application's entry point
// E.g. Program.cs
ExcelTypeRegistry.Register<Foo>(foo =>
{
    foo
        .Property(p => p.Name, prop => { prop.Column("A"); })
        .Property(p => p.Created, prop => { prop.Column("B"); });
});

Writing to Excel

using (var workbook = new ExcelWorkbook())
{
    workbook.Write(new Foo
    {
        Name = "bar",
        Created = DateTime.Now
    });
    workbook.SaveAs("HelloWorld.xlsx");
}

Reading from Excel

using (var workbook = new ExcelWorkbook("HelloWorld.xlsx"))
{
    foreach (var rowData in workbook.Read<Foo>())
    {
        Console.WriteLine(rowData.RowNumber);

        var foo = rowData.Entity;
        Console.WriteLine(foo.Name);
        Console.WriteLine(foo.Created);
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages