CN109471897A - By excel Context resolution and the method into database is stored based on SpringMVC frame - Google Patents
By excel Context resolution and the method into database is stored based on SpringMVC frame Download PDFInfo
- Publication number
- CN109471897A CN109471897A CN201811344052.5A CN201811344052A CN109471897A CN 109471897 A CN109471897 A CN 109471897A CN 201811344052 A CN201811344052 A CN 201811344052A CN 109471897 A CN109471897 A CN 109471897A
- Authority
- CN
- China
- Prior art keywords
- excel
- database
- springmvc
- context resolution
- entity
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The method into database by excel Context resolution and is stored based on SpringMVC frame the invention discloses a kind of, excel table is handled using poi packet, jxl.jar packet is used compared with traditional, size of code of the present invention is less, and by and SpringMVC combination so that logic is relatively sharp, code level is more clearly demarcated, it is also not easy to make mistakes when parsing content, if developer needs to complete similar functions during the work time, working efficiency can be greatly improved using this method.
Description
Technical field
The present invention relates to database technical fields, more particularly to a kind of SpringMVC frame that is based on is by excel Context resolution
And store the method into database.
Background technique
SpringMVC frame is one of most common frame in current web exploitation, and excel is also that people are raw as table
It is commonly used in work, such as all kinds of reports, inventory etc..So often having in web system and importing excel table and handle
Context resolution in table, which comes out, stores such demand into database.
Currently, main realize that the implementation method by excel Context resolution and storage to database is all to utilize jxl.jar packet
It realizes, but jxl.jar packet is not provided with and can directly parse the code of excel content and realize, therefore, parses and stores
Excel just becomes that a size of code is very big, is also easy to the task of parsing error.And the people for being engaged in JAVA WEB exploitation
For member, there is a kind of simple and convenient method for parsing excel table content under SpringMVC frame and storing to database
Working efficiency can greatly be improved.
Summary of the invention
In view of the above-mentioned problems, the present invention is proposed to be based on SpringMVC frame for excel Context resolution and be stored to database
In method, the problem to be solved in the present invention be currently undertaken by JAVA WEB exploitation personnel needing to complete EXCEL content solution
Size of code is very big when the task of analysis and storage and is easy the problem of parsing error.
The present invention through the following technical solutions to achieve the above objectives:
By excel Context resolution and the method into database is stored based on SpringMVC frame, comprising the following steps:
Step 1: importing poi packet, excel archives can be written and read after importing;
Step 2: database table corresponding to newly-built and excel gauge outfit, creates entity class corresponding with the table;
Step 3: obtaining excel table from front end page and passing to rear end;
Step 4: creating book with obtained excel table, book row and column is obtained;
Step 5: acquiring unit lattice data, and it is assigned to the corresponding field of entity class;
Step 6: storing obtained entity.
Further embodiment is: in the step 2, database table corresponding with excel gauge outfit is created, excel table
In each gauge outfit be set as each field of database table one by one, after the completion of creation, further according to each word of the database table
Section creation correspondent entity class.
Further embodiment is: in the step 3, submitting a form list front end is needed the excel table that uploads
Submit to backstage.
Further embodiment is: in the step 4, creating book by the obtained excel table of poi packet, and then obtain
To the row and column of book.
Further embodiment is: in the step 5, the data of each cell, and handle are traversed with the mode of nesting circulation
Obtained data are assigned to the corresponding field of entity class.
Further embodiment is: in the step 6, calling the method for preservation entity in SpringMVC frame by gained
To entity store into database.
The beneficial effects of the present invention are:
Of the invention by excel Context resolution and stores the method into database based on SpringMVC frame, uses
Poi packet handles excel table, uses jxl.jar packet compared with traditional, and size of code of the present invention is less, and by with
The combination of SpringMVC, so that logic is relatively sharp, code level is more clearly demarcated, parse content when it is also not easy to make mistakes, if
Developer needs to complete similar functions during the work time, can greatly improve working efficiency using this method.
Detailed description of the invention
It to describe the technical solutions in the embodiments of the present invention more clearly, below will be to embodiment or description of the prior art
In required practical attached drawing be briefly described, it should be apparent that, the accompanying drawings in the following description is only the one of the present embodiment
A little embodiments for those of ordinary skill in the art without creative efforts, can also be according to these
Attached drawing obtains other attached drawings.
Fig. 1 is the side provided by the invention based on SpringMVC frame by excel Context resolution and storage into database
The flow diagram of method.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, technical solution of the present invention will be carried out below
Detailed description.Obviously, the described embodiment is only a part of the embodiment of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, those of ordinary skill in the art without making creative work it is obtained it is all its
Its embodiment belongs to the range that the present invention is protected.
As shown in Figure 1, the method into database by excel Context resolution and is stored based on SpringMVC frame, including
Following steps:
Step 1: importing poi packet, POI packet full name is Apache Poi, be one with JAVA freely increasing income of writing across
Platform JAVA API, Apache POI provide API to Java formula to Microsoft Office (Excel, WORD,
PowerPoint, Visio etc.) format archives are read and the function write.By introducing poi packet in the pom.xml file of maven,
Poi packet can be imported to this into project, excel archives can be written and read after importing;
Step 2: database table corresponding to newly-built and excel gauge outfit, creates entity class corresponding with the table;Creation with
The corresponding database table of excel gauge outfit is one by one set as each gauge outfit in excel table each field of database table,
After the completion of creation, correspondent entity class is created further according to each field of the database table.
Step 3: obtaining excel table from front end page and passing to rear end;Submit a form list that front end is needed
The excel table of biography submits to backstage.
Step 4: creating book with obtained excel table, book row and column is obtained;It is obtained by poi packet use
Excel table creates book, and then obtains the row and column of book.
Step 5: acquiring unit lattice data, and it is assigned to the corresponding field of entity class;It is traversed often with the mode of nesting circulation
The data of a cell, and obtained data are assigned to the corresponding field of entity class.
Step 6: storing obtained entity.Call the method for saving entity in SpringMVC frame will be obtained
Entity is stored into database.
The specific implementation process and code of one embodiment of the present of invention are as follows:
Poi packet can operate the workbook of excel table, sheet, cell, and Workbook corresponding is table sheet
Body, and a sheet in the corresponding table of sheet, a table can correspond to multiple sheet, a cell corresponding is in table
One grid, and poi packet can be carried out operating to these three objects.
It, only need to matching in maven due to being that directly can import poi packet using maven under SpringMVC frame
The dependence that poi packet is added in file is set, the code that addition poi packet relies on is as follows:
After having added dependence, so that it may it is corresponding with excel gauge outfit to create field in the database according to the gauge outfit of table
Table after creating table, needs to create the corresponding entity class of the table again, and the member of entity class field one-to-one correspondence in table is
It can.
Due to being the exploitation carried out under SpringMVC frame, it is therefore desirable to which the excel table of parsing is after passing to from foreground
Platform.Specific method is then to submit form list by being put among list needing to upload to file, needs are parsed
Excel file is transmitted to backstage, and the code of list is as follows:
On backstage, need to finish writing method of reseptance in the controller layer of frame to receive the excel sent back from foreground
Table, code are as follows:
The code excel table ready to receive sent back from foreground herein, is handled this document so as to subsequent.It has received
After the excel file for passing backstage back from foreground, so that it may start handle to excel table.
Firstly the need of judging whether this document is excel2003 file, because excel2003 and excel2007 format is
It is different, it is therefore desirable to do handle respectively here, the code for judging whether table is excel2003 is as follows:
After the version for having judged excel table again, need to create different workbook according to different editions, code is such as
Under:
Different workbook has thus been created according to excel table version, next can to workbook into
Row is handled.
Firstly the need of the row and column for obtaining the workbook, code is as follows:
For this sentences only one sheet of the table, after obtaining total line number and total columns, so that it may to the sheet into
Row is nested to be looped through, and obtains the value of each cell, and the value each cell is corresponding with entity instance.Its code is as follows:
After the above code process is complete, the set of entity instance corresponding with each cell value of excel has just been obtained;It arrives
This, just completes the parsing of excel content, and content has been stored among entity instance.
After the parsing for having handled excel table content, so that it may carry out storage to the content of parsing and handle;Its main generation
Code is as follows:
For (Student stu:studentList)
baseDao.save(stu);
}
This is arrived, the content of excel table is parsed under SpringMVC frame and storage is just completed to database.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain
Lid is within protection scope of the present invention.Therefore, protection scope of the present invention should be based on the protection scope of the described claims.
It is further to note that specific technical features described in the above specific embodiments, in reconcilable situation
Under, it can be combined in any appropriate way, in order to avoid unnecessary repetition, the present invention is to various possible combinations
No further explanation will be given for mode.In addition, various embodiments of the present invention can be combined randomly, as long as its
Without prejudice to thought of the invention, it should also be regarded as the disclosure of the present invention.
Claims (6)
1. by excel Context resolution and storing the method into database based on SpringMVC frame, which is characterized in that including
Following steps:
Step 1: importing poi packet, excel archives can be written and read after importing;
Step 2: database table corresponding to newly-built and excel gauge outfit, creates entity class corresponding with the table;
Step 3: obtaining excel table from front end page and passing to rear end;
Step 4: creating book with obtained excel table, book row and column is obtained;
Step 5: acquiring unit lattice data, and it is assigned to the corresponding field of entity class;
Step 6: storing obtained entity.
2. according to claim 1 by excel Context resolution and store the side into database based on SpringMVC frame
Method, which is characterized in that in the step 2, database table corresponding with excel gauge outfit is created, each of excel table
Gauge outfit is set as each field of database table one by one, after the completion of creation, further according to each field creation pair of the database table
Answer entity class.
3. according to claim 1 by excel Context resolution and store the side into database based on SpringMVC frame
Method, which is characterized in that in the step 3, after submitting a form list to submit to come the excel table that front end needs are uploaded
Platform.
4. according to claim 1 by excel Context resolution and store the side into database based on SpringMVC frame
Method, which is characterized in that in the step 4, book is created by the obtained excel table of poi packet.And then obtain book
Row and column.
5. according to claim 1 by excel Context resolution and store the side into database based on SpringMVC frame
Method, which is characterized in that in the step 5, the data of each cell are traversed with the mode of nesting circulation, and obtained number
According to the corresponding field for being assigned to entity class.
6. according to claim 1 by excel Context resolution and store the side into database based on SpringMVC frame
Method, which is characterized in that in the step 6, call the method for preservation entity in SpringMVC frame by obtained entity
It stores in database.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811344052.5A CN109471897A (en) | 2018-11-12 | 2018-11-12 | By excel Context resolution and the method into database is stored based on SpringMVC frame |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811344052.5A CN109471897A (en) | 2018-11-12 | 2018-11-12 | By excel Context resolution and the method into database is stored based on SpringMVC frame |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109471897A true CN109471897A (en) | 2019-03-15 |
Family
ID=65672118
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811344052.5A Pending CN109471897A (en) | 2018-11-12 | 2018-11-12 | By excel Context resolution and the method into database is stored based on SpringMVC frame |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109471897A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111814442A (en) * | 2020-06-29 | 2020-10-23 | 四川长虹电器股份有限公司 | Excel data processing method based on SpringBoot |
CN111931460A (en) * | 2020-07-02 | 2020-11-13 | 上海微亿智造科技有限公司 | Variable-row-supporting Excel file analysis method and system |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102609483A (en) * | 2012-01-19 | 2012-07-25 | 北京神州数码思特奇信息技术股份有限公司 | General Excel import method based on configuration |
CN108460007A (en) * | 2018-02-11 | 2018-08-28 | 悦锦软件系统(上海)有限公司 | A kind of automation report logic engine and method |
-
2018
- 2018-11-12 CN CN201811344052.5A patent/CN109471897A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102609483A (en) * | 2012-01-19 | 2012-07-25 | 北京神州数码思特奇信息技术股份有限公司 | General Excel import method based on configuration |
CN108460007A (en) * | 2018-02-11 | 2018-08-28 | 悦锦软件系统(上海)有限公司 | A kind of automation report logic engine and method |
Non-Patent Citations (1)
Title |
---|
HEKAIJIN_001: "maven+springmvc+POI导入Excel", 《HTTPS://BLOG.CSDN.NET/WEIXIN_35751376/ARTICLE/DETAILS/60139028》 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111814442A (en) * | 2020-06-29 | 2020-10-23 | 四川长虹电器股份有限公司 | Excel data processing method based on SpringBoot |
CN111931460A (en) * | 2020-07-02 | 2020-11-13 | 上海微亿智造科技有限公司 | Variable-row-supporting Excel file analysis method and system |
CN111931460B (en) * | 2020-07-02 | 2021-09-10 | 上海微亿智造科技有限公司 | Variable-row-supporting Excel file analysis method and system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108052320B (en) | Method for converting binary structure body into JSON object | |
CA2610208A1 (en) | Learning facts from semi-structured text | |
CN109471897A (en) | By excel Context resolution and the method into database is stored based on SpringMVC frame | |
Qu et al. | Towards interoperability and reusability of learning resources: A SCORM-conformant courseware for computer science education | |
US10089285B2 (en) | Method to automatically convert proposal documents | |
CN101650745A (en) | Method and device for rapidly generating WEB page based on data definition | |
CN109558574A (en) | A kind of generation online testing examination question processing method | |
CN104765721B (en) | Layout processing method and processing device | |
CN103399934A (en) | Form data transmission and storage method | |
CN110991152B (en) | Method and system for step-by-step data acquisition and automatic summarization | |
CN103177614A (en) | Automatic convenient homework system | |
CN105701743A (en) | Cloud word learning system and method | |
CN108804407A (en) | A kind of newer method and apparatus of quick response e-bidding document template | |
Black et al. | Teach Indigenous knowledge alongside science | |
Burris et al. | Universal access to a quality education: Research and recommendations for the elimination of curricular stratification | |
CN107908377A (en) | The analytic method of font coding information and its device and application in print language | |
Amadi et al. | Sustainable Rural Livelihoods: Elusive Post-Colonial Development Project in Nigeria | |
CN114610743A (en) | Structured query language statement processing method, system, device, and medium | |
Neubert et al. | LHCb analysis preservation roadmap | |
Papadakis et al. | Entity resolution: Past, present and yet-to-come: From structured to heterogeneous, to crowd-sourced, to deep learned | |
Bärtschi et al. | Reflecting on the symmetry of ecosystem tipping points. The influence of trait dissimilarity and environmental driver dynamics in a simple ecosystem model. | |
Entjes | Linking Maritime Datasets to Dutch Ships and Sailors Cloud-Case studies on Archangelvaart and Elbing | |
Pullen et al. | Supporting Coalition Battle Management Language Experiments with Scripted Web Services | |
Kolhatkar | XML Based Representation of DFD | |
US20140181640A1 (en) | Method and device for structuring document contents |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190315 |