Scan Excel table data and save to SQL Server (Asp.Net MVC 5 C#)

Asked

Viewed 289 times

1

I have an input file that the user will upload the spreadsheet, I need to check if it is .xlsx or .xls and scan the data from this spreadsheet. After that, I need to save to Sql server those items.

About Checking Extension Use This:

var ext = Path.GetExtension(file.FileName);

var allowedExtensions = new[] { ".xlsx", ".xls" };

if(allowedExtensions.Contains(ext)){ //codigo }

Now my biggest doubt is even in sweeping the spreadsheet data and sends them to the bank.

Table that will receive the data contains the columns:

- ID
- Registro
- Nome
- Ativo

I’m starting with Asp.net, it may be very simple and sorry for that.

  • It may even be duplicated: How to scan data from an Excel spreadsheet

  • I am very lay and could not imagine this article in my problem, where I pass a connection string, but the user who will upload the file.. If it’s something very simple, I’m sorry, but I can’t see what I need to do...

  • asking on satckoverflow in English, were more attentive to me and gave me this solution: http://csharp.net-informations.com/excel/csharp-read-excel.htm winforms, but very easy to adapt...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.