i am using ASP.Net Core Web Api and writing the Api which return the data in nested form and its done the Api returning the data like i want now i want to export that data in excel sheet with EPPlus, here is data sample
[
{
"BIDFormCategoryId": "S1",
"BIDFormCateogry": "Computer Monitor",
"FirstLevel": [
{
"BIDFormId": "S1-27",
"BIDFormComponent": "Inspiron27",
"SecondLevel": [
{
"ObjectName": "Optiflex 27 inch high resolution monitor",
"Quantity": 15000,
"Length": 56,
"Area": 85,
"Volume": 1587
}
]
},
{
"BIDFormId": "S1-22",
"BIDFormComponent": "Inspiron22",
"SecondLevel": [
{
"ObjectName": "Optiflex 22 inch high resolution monitor",
"Quantity": 1500,
"Length": 45,
"Area": 65,
"Volume": 875
}
]
}
]
},
{
"BIDFormCategoryId": "S2",
"BIDFormCateogry": "Laptop Monitor",
"FirstLevel": [
{
"BIDFormId": "S1-27",
"BIDFormComponent": "Inspiron27",
"SecondLevel": [
{
"ObjectName": "Optiflex 27 inch high resolution monitor",
"Quantity": 15000,
"Length": 56,
"Area": 85,
"Volume": 1587
}
]
},
{
"BIDFormId": "S1-22",
"BIDFormComponent": "Inspiron22",
"SecondLevel": [
{
"ObjectName": "Optiflex 22 inch high resolution monitor",
"Quantity": 1500,
"Length": 45,
"Area": 65,
"Volume": 875
}
]
}
]
}
What I have tried:
using(ExcelPackage excelPackage = new ExcelPackage())
{
excelPackage.Workbook.Properties.Author = "Samee";
excelPackage.Workbook.Properties.Title = "Architecture Review";
excelPackage.Workbook.Properties.Created = DateTime.Now;
ExcelWorksheet excelWorksheet = excelPackage.Workbook.Worksheets.Add( "ARCHITECTURE" );
for(int i = 0; i < meta.Count + 1; i++)
{
excelWorksheet.Cells[1, i].Value = meta.ToString()[i];
}
for(int i = 0; i < meta.Count - 1; i++)
{
for(int j = 0; j < meta.Count; j++)
{
excelWorksheet.Cells[i + 2, j + 1].Value = meta.ToString()[j];
}
}
}