how to column names of excel sheet into list dynamically using asp.net

Viewed 28
public async Task<IActionResult> UploadFileViaModel([FromForm] FileInputModel model)
{
    if (model == null || model.FileToUpload == null || model.FileToUpload.Length == 0)
        return Content("file not selected");

    var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", model.FileToUpload.FileName);

    using (var stream = new FileStream(path, FileMode.Create))
    {
        await model.FileToUpload.CopyToAsync(stream);
    }
    return RedirectToAction("Files");
}

This is my controller, but I want user to give excel sheet and I need to get the columns dynamically from the user uploaded excel sheet.

0 Answers
Related