PanoramicData.SheetMagic

A library for easily saving/loading generic lists to/from XLSX workbooks.


Keywords
License
MIT
Install
Install-Package PanoramicData.SheetMagic -Version 3.0.101

Documentation

PanoramicData.SheetMagic

Codacy Badge Commit Activity

Easily save/load from/to Excel (XLSX) documents using generics in C#

Writing to a file

// Write a list of items to an XLSX file
var things = new List<Thing>
{
	new Thing
	{
		PropertyA = "Value 1",
		PropertyB = 1
	},
	new Thing
	{
		PropertyA = "Value 2",
		PropertyB = 2
	},
};
var fileInfo = new FileInfo($"Output {DateTime.UtcNow:yyyyMMddTHHmmss}Z.xlsx");
using var workbook = new MagicSpreadsheet(fileInfo);
workbook.AddSheet(things);
workbook.Save();

Reading from a file

// Read a list of items from an XLSX file
using var workbook = new MagicSpreadsheet(fileInfo);
workbook.Load();
// Use default worksheet
var cars = workbook.GetList<Car>();
// Use a different worksheet
var animals = workbook.GetList<Animal>("Animals");