I have an excel file I need to save all your information in a database
I'm working with c # mvc and javascript.
And to capture the file I have:
<input type="file" id="Upload">
I need your support.
Thank you.
You can try this way to read the excel data, the list is filled, this list you can go through and save the information of the excel, with your method you have to save the information this is the code
using System.Text;
using System.Data.OleDb;
using System.Data;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
String file = "D:\xampp\xampp\htdocs\sln-ats\files\ATS_SLNKEY_20121204.xls";
OleDbConnection con = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + file +
";Mode=ReadWrite;Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\"");
con.Open();
DataSet dset = new DataSet();
OleDbDataAdapter dadp = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", con);
dadp.TableMappings.Add("tbl", "Table");
dadp.Fill(dset);
DataTable table = dset.Tables[0];
for (int i = 0; i < table.Rows.Count; i++)
{
Console.Write(table.Rows[i][0] + "\t" + table.Rows[i][1] + "\n");
}
Console.ReadKey();
}
}
}