1
Gentlemen, I have the following problem: I created the code below, I made some changes, however I cannot import my file. My application is in .NET, and the database is the Oracle Sql, and adapted the library EPPLUS.
If anyone has a north of what I can do to improve my code, thank you, and if anyone has any suggestions of what I might be doing, thank you also.
I tried to use the Dapper, but I could not.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;
using System.IO;
namespace Teste1.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Title = "Home Page";
            return View();
        }
        [HttpGet]
        [Route("Import")]
        public void ImportExcel()
        {
            //Esta dando erro na minha linha aqui tbm->  using (ExcelPackage xlPackage = new E(new FileInfo(@"C:\YourDirectory\sample.xlsx")))
            var myWorksheet = xlPackage.Workbook.Worksheets.First(); //selecionando o arquivo
            var totalRows = myWorksheet.Dimension.End.Row;
            var totalColumns = myWorksheet.Dimension.End.Column;
            var sb = new StringBuilder(); //Estes são seus dados
            for (int rowNum = 1; rowNum <= totalRows; rowNum++) //selecionando a linha
            {
                var row = myWorksheet.Cells[rowNum, 1, rowNum, totalColumns].Select(c => c.Value == null ? string.Empty : c.Value.ToString());
                sb.AppendLine(string.Join(",", row));
            }
        }
    }
}
What exactly is the mistake?
– Leandro Angelo