Objective:
With the popularization of ASP. Aries, just a little bit of leisure, quickly fill in the Excel Import function tutorial.
Excel import features, divided into four: single-table configuration (top), multi-table Advanced Configuration (middle), configuration rules (under), Code writing (external).
This article describes the single-table configuration feature.
1, configure the table header, the need to import the hook to hit.
For a formatted configuration (when you generate an Excel template, it also becomes a drop-down item, and when you import it back, it can also translate the drop-down in Chinese back to the value)
Description
Tick three, indicating import only imports three. Where the unique (key) is checked, the imported data is inserted according to the unique key (the presence is updated, does not exist). You can also tick multiple unique keys to make a composite (the default is: and relationship).
2. Export Template
When you click Export template on the page, automatically generated template files are automatically ejected according to the selected import options.
PS: If an import option is not checked (unless advanced import rules are configured), the import and export template two buttons are not displayed.
Description
The exported file name, which can be modified in the configuration maintenance item, is generated by default by the system based on the rules (description of the table name, or menu name).
Next, fill in the data in the template and then import to finish.
How does the system know which table to import?
On the list page: var dg = new AR. DataGrid ("V_sys_userlist", "Sys_user", "grid");
The second parameter is the table name: it determines the name of the action table to be added or deleted and imported.
Other instructions:
Of course, there are some problems with the example import here. Because the password stored in the database is encrypted, the password written to the user is definitely clear, so there is a lack of a cryptographic conversion. In this case, you need to complement the code: rewrite the method before the import, write a loop, the password is converted to dense data, the other unchanged. If you fill in the code, you can look at the following out of the code to write an article.
Results of the import:
If the import is successful, prompt:
If the import fails, you are prompted with an exception and the wrong Excel download file pops up:
The error message for each line is marked with the wrong Excel file:
Summarize:
Tasks that are completed by configuration in the configuration header are usually suitable for single-table imports and do not have complex transformations.
If it is a single table, but also requires a complex conversion, such as password encryption, is not a simple drop-down translation can handle the situation, you need to complement the code processing.
For complex insert configurations with multiple tables, take a look at the next article.
ASP. Aries Advanced Development Tutorial: Single-table configuration for Excel import (top)