Import excel sheet
How to do i import excel sheet data into my database using only c# application?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Jacke Elis36 pointsPosted Jan 27, 2015, 2:25 AM EST
DataTable table = ExcelFile.Load("Sample.xlsx") .Worksheets .ActiveWorksheet .CreateDataTable( new CreateDataTableOptions()); using (var conn = new SqlConnection("Sample connection ...")) { conn.Open(); using (var bulkCopy = new SqlBulkCopy(conn)) bulkCopy.WriteToServer(table); }You can use that first Load method to read both XLS and XLSX files in .NET.