[Nuget]:NPOI
This is a Nuget that I use in almost every .NET Core project to export files in an Excel format without excel on the PC.
Link: https://www.nuget.org/packages/npoi
Site: https://github.com/nissl-lab/npoi
What it does: Create real Excel files – not just CSV
Usage:
var wb = new XSSFWorkbook();
var sheet = wb.CreateSheet(“Contractors”);
for (int i = 0; i < allContractors.Count; i++)
{
var contractor = allContractors[i];
IRow row = sheet.CreateRow(i);
for (int j = 0; j < contractor.Length; j++)
{
var cell = row.CreateCell(j);
cell.SetCellValue(contractor[j].ToString());
}
}
wb.Write(File.OpenWrite(“Contractors.xlsx”));
Leave a Reply