Import Data

Development tools and key technologies: Visual Studio
Author: Xiaoguang Bin
wrote Time: May 15, 2019

When we want to import the data on the page, often requires some specific steps, and these steps and a little complicated, so I'll use what I understand, to simply look at how to import the data
First we need to import a pop-up mode state box, modal box contents selectively xls files, download and import templates into the content database, then we need to first download the template, and then select the xls file to save the template data to a temporary table, and finally the temporary table save data to the database, which is the idea that we import, we will first look at the code
Here Insert Picture Description
above js is in accordance with our ideas to write out a step by step, when we save excel spreadsheet data into a temporary table, do when some simple determination, and submit the form, and finally the data temporarily saved to the database tables on the line, saved to the database, we need only side of the path controller request method, each step is needed on our js controller method request, then we look at the method of the controller
first download the template is square We get to the path where the template, and then determine whether there is a template, if you get to the name of the file and returns the file, otherwise it returns the prompt
Here Insert Picture Description
followed by the method into a temporary table, access to the file is read, declare a binary array storage file, convert the file to a binary array, and then the binary array into a memory stream, then NPOI reference data stream read into memory excel, this is what we probably thinking, there is a query to get some judgment and data, extract data temporary table, and they were paging operation, not setting them up here
Here Insert Picture Description
last method is saved to the database, and a foreach loop, then check whether a duplicate of the existing data in the database, followed by some new and determining the field to be saved to the database when the data is increased. So that the entire process of importing data is complete, more than just a simple understanding of the import personal data, if wrong, please correct me! ! !
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/qq_44505797/article/details/90268240