Skip to content

Save/Load C# generics to/from Excel (XLSX) spreadsheets, easily

License

Notifications You must be signed in to change notification settings

panoramicdata/PanoramicData.SheetMagic

Repository files navigation

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");

About

Save/Load C# generics to/from Excel (XLSX) spreadsheets, easily

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published