Gentlemen, I have the following problem: I created the code below, I made some changes, however I can not import my file. My application is in .NET , and the database is the Oracle Sql , and I have adapted the EPPLUS library.
If anyone has a sense 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 too.
I tried to use 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));
}
}
}
}