Home > front end >  Using NPOI to import the data
Using NPOI to import the data

Time:12-01

1, import data
Download the template:
Front desk: (1) allows users to download the import data template
Background: (1) to determine whether a template file is
1. Access to the file
2. To determine whether a file exists
3. Return in the form of stream file
Import data:
Front desk: (1) need to submit documents, to determine whether the user to select file Excel file
(2) use a JavaScript XMLHttpRequest upload file
1. Create FormData object
2. Add need to upload the file to create the FormData object
3. Create the XMLHttpRequest object
4. Set the submission as well as the path, note: submission must be submitted for the POST, GET
Have limited length, if the file is greater than the length of the GET submitted to the maximum length of the file
Will be truncated, will affect the back of the operation
5. Send data
6. Set the callback (pop-up message, etc.)
Background: (1) will upload a file into a workbook
1. Access file extension
2. To determine whether the file Excel file
3. Create a consistent with that of the import file size to the size of the binary array
4. The file is converted into a binary array
5. Converts binary array memory flow
6. The memory stream into a workbook
(2) converts workbook data table
1. To determine whether there is a worksheet in the workbook
2. Get the first worksheet
3. Determine whether the worksheet for the empty table
4. Create a data table (DataTable)
5. Get to work in the table header lines
Number 6. Get the worksheet header columns, USES when traversing the header row
7. Get the worksheet rows, when used to traverse the worksheet data using
8. Head traversing work table row data, generate the data form the first line in the data (data table
Header row)
9. Work through the data in the table, the data table data
10. Remove the data in the table blank lines
(3) the data validation and create a need to save the object
1. The corresponding table in the query the database information
2. Create a container to store all data, for data check weight
3. Create a store need additional data container, save for the last data
4. Traversing the data form. Note: the first 5/6/7/8/9 step operation are in the loop
5. Remove the current cycle of row data, convenient data validation
6. Create a table object needs to be saved, save the current cycle of data
7. According to the requirements of each line to check each column of the data, check again, if through the data
Is added to the table objects
8. Add table objects to store all the data in the container
9. Will need to add data table objects added to the storage containers
4. Save the data
1. To determine whether there is a need to save the data, namely whether store new data container is empty
2. If two tables or more than two tables involved, the open transaction to ensure unity of the data
New data
3.4.
save added to the database5. If the open transaction, need to commit the transaction, otherwise don't need
6. Return success message

CodePudding user response:

  • Related