HOW TO IMPORT EXCEL DATA TO DATABASE USING AJAX AND CLOSEDXML LIBRARY IN MVC C#
HTML-код
- Опубликовано: 14 дек 2024
- In this tutorial we will learn how to import data from excel file to database (SQL Server), we also use MVC C# database first framework, ajax post and ClosedXML library. I hope you are familiar with those framework/library.
#mvc-c#, #databasefirst, #closedxml, #sqlserver, #excelimportusingaJax
All content of this channel aims to share how to program using ASP.Net C# programming language.
if you feel this channel beneficent you, don't be hesitate for subscribe, press the like button and turn on the bell notification.
Hi, I've managed to get some of my data to import but not all columns. What code do I need to import 3 Excel columns (which are numeric) and store them in an int field and decimal fields? Those three columns are failing to import. The int field just shows 0 for all records which the two fields that are decimal are empty. Thank you.
Did you assigned your data from excel to correct column of the table? i am worried you assign the data to wrong column. Will be better if you debug your code to see if there any mistake on it.
@@lahilatech5946 thank you so much for your swift reply. I worked it out just now. I just had to put Convert.ToInt32(ProjectID)!!
@@sallyparkes4329 yes, you need to converted it. decimal.Parse(your string) for decimal column
I have trying it but the button is not working
wouldn't this take a significant time for a file with 10s of thousands of rows? Normally you would want to save a data upload using a bulk insert mechanism.
How to avoid duplicate records insert
it's simple, you can achieved that by doing validation all items on excel list before you saved item to the database.
I gett in error on $, document.ready(function (){})
Have you include the jquery file correctly?
@@lahilatech5946 yes need to any packages ?
vendors.bundle.js:1 Uncaught TypeError: Illegal invocation
at r (vendors.bundle.js:1:71005)
at Se (vendors.bundle.js:1:70897)
at _.param (vendors.bundle.js:1:71196)
at Function.ajax (vendors.bundle.js:1:74515)
at HTMLButtonElement. (UploadFromExcel.js:23:19)
at HTMLButtonElement.dispatch (vendors.bundle.js:1:41525)
at g.handle (vendors.bundle.js:1:39555)
Hi Mohammad Imran, i thought the problem is on your ajax post parameters. can you post your ajax function?