Click here to Skip to main content
15,890,440 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi i want to iterate through a list of data and write this to excel using EPPlus, but im unsure of the syntax, and how to do it. Any advice will be appreciated

What I have tried:

This is my method

public ActionResult ExportToExcel(string datepicker, string datepicker1)
{
    using (new ExcelPackage())
    {

        var startDate = DateTime.Parse(datepicker).AddHours(7);
        var endDate = DateTime.Parse(datepicker1).AddHours(7);

        var dataSet = CheckRecords.GetListofRecordsForExcelReport(startDate, endDate);

        string path = "C:\\checks\\templateChecks.xlsx";

        FileInfo Files = new FileInfo(path);
        ExcelPackage excel = new ExcelPackage(Files);

        var worksheet = excel.Workbook.Worksheets["Sheet1"];

        for (int i = 0; i < dataSet.Count; i++)
        {

        }


        excel.SaveAs(new FileInfo(@"c:\checks\templateChecks1.xlsx"));
    }

    return View("Report");
}
Posted
Updated 16-Nov-17 22:52pm
v2
Comments
Karthik_Mahalingam 17-Nov-17 4:52am    
each datatable in separate sheet?
Patrice T 17-Nov-17 5:40am    
try to read documentation and find tutorials.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900