An Excel import and export method and system based on data monitoring
Through the excel import and export method based on data monitoring, using Easy Excel tools and listener mechanism, the problems of low performance and memory overflow during the excel import and export process in the existing technology are solved, and efficient and stable large-data import and export are achieved.
Patent Information
- Application Number
- CN202210518434.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-12
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2042-05-12
AI Technical Summary
The prior art has problems of low performance and memory overflow (OOM) in the import and export process of excel files, especially when processing large amounts of data, which leads to slow or failure of import and export process.
The excel import and export method based on data monitoring is adopted. By obtaining the byte input and output streams and rows of the to-process files, a data model is built to map files and database fields, and the Easy Excel tool is used for import and export processing. The listener mechanism is used to read and write data line by line to avoid loading all data into memory at one time.
Improves the efficiency of import and export of excel files, reduces memory usage, avoids OOM problems, and supports large data import and export operations.
Smart Images

Figure CN114970474B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and particularly to an Excel import and export method and system based on data monitoring. Background Art
[0002] During the work process, there are a large number of unit data that need to be imported and exported in Excel format to achieve manual interaction of data between lower-level and upper-level. POI under Apache is used to implement Excel import and export. The encoding logic implementation is complex, and the manually encapsulated logic code has high requirements for server performance and memory capacity. Otherwise, the import and export process is slow, and even server memory overflow (OOM) and other situations may occur. In this case, there is an urgent need for a tool that can replace the POI tool and support Excel friendly to implement specific Excel functions. Therefore, the tool for solving the problem is positioned at the open-source Easy Excel tool. Summary of the Invention
[0003] The purpose of the present invention is to provide an Excel import and export method and system based on data monitoring, so as to achieve the purpose of improving the efficiency of Excel file import and export by being compatible with different data types.
[0004] To achieve the above purpose, the present invention provides the following solutions:
[0005] An Excel import and export method based on data monitoring, comprising:
[0006] Obtaining the byte input and output streams and row data of the file to be processed; the byte input and output streams include a byte input stream and a byte output stream; the row data includes imported row data and exported row data;
[0007] Constructing a data model according to the row data; the data model is the mapping relationship between the file to be processed and the database fields;
[0008] Determining the Class bytecode of the file to be processed according to the data model;
[0009] Performing import and export processing according to the byte input and output streams, the data model, the Class bytecode, and the listener.
[0010] Optionally, the performing import and export processing according to the byte input and output streams, the data model, the Class bytecode, and the listener specifically includes:
[0011] When the file to be processed is an import file, reading according to the byte input stream, the data model, the Class bytecode, and the listener to obtain the file imported into the database;
[0012] When the file to be processed is an export file, write according to the byte output stream, the data model, the Class bytecode, and the listener to obtain an excel file.
[0013] Optionally, when the file to be processed is an import file, read according to the byte input stream, the data model, the Class bytecode, and the listener to obtain a file for importing into the database, specifically including:
[0014] Use the byte input stream, the Class bytecode, and the listener as input parameters, and use the excel read builder to build a read workbook.
[0015] Perform SAX parsing according to the read workbook and the data model to obtain a file for importing into the database.
[0016] Optionally, before using the byte input stream, the Class bytecode, and the listener as input parameters and using the excel read builder to build a read workbook, it further includes:
[0017] Judge whether the excel file reader in the initialization environment is initialized successfully; if so, use the byte input stream, the Class bytecode, and the listener as input parameters, and use the excel read builder to build a read workbook; if not, interrupt the program.
[0018] An excel import and export system based on data listening, including:
[0019] An acquisition module, used to acquire the byte input and output streams and row data of the file to be processed; the byte input and output streams include a byte input stream and a byte output stream; the row data includes import row data and export row data;
[0020] A construction module, used to construct a data model according to the row data; the data model is the mapping relationship between the file to be processed and the database fields;
[0021] A Class bytecode determination module, used to determine the Class bytecode of the file to be processed according to the data model;
[0022] An import and export processing module, used to perform import and export processing according to the byte input and output streams, the data model, the Class bytecode, and the listener.
[0023] Optionally, the import and export processing module specifically includes:
[0024] An import module, which is used to read according to the byte input stream, the data model, the Class bytecode and the listener when the file to be processed is an import file, so as to obtain a file for importing into the database;
[0025] An export module, which is used to write according to the byte output stream, the data model, the Class bytecode and the listener when the file to be processed is an export file, so as to obtain an excel file.
[0026] Optionally, the import module specifically includes:
[0027] A construction unit, which is used to use an excel read builder to construct a read workbook with the byte input stream, the Class bytecode and the listener as input parameters;
[0028] A parsing unit, which is used to perform SAX parsing according to the read workbook and the data model to obtain a file for importing into the database.
[0029] Optionally, it further includes:
[0030] A judgment module, which is used to judge whether the excel file reader in the initialization environment is initialized successfully; if so, use an excel read builder to construct a read workbook with the byte input stream, the Class bytecode and the listener as input parameters; if not, interrupt the program.
[0031] According to the specific embodiments provided by the present invention, the following technical effects are disclosed by the present invention:
[0032] The excel import and export method and system based on data monitoring provided by the present invention obtain the byte input and output streams and row data of the file to be processed; the byte input and output streams include a byte input stream and a byte output stream; the row data includes import row data and export row data; construct a data model according to the row data; the data model is the mapping relationship between the file to be processed and the database fields; determine the Class bytecode of the file to be processed according to the data model; perform import and export processing according to the byte input and output streams, the data model, the Class bytecode and the listener. The present invention improves the efficiency of excel file import and export by being compatible with different data types. Description of the Drawings
[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0034] Figure 1 Flow chart of the Excel import and export method based on data monitoring provided by the present invention;
[0035] Figure 2 Excel import flow chart provided by the present invention;
[0036] Figure 3 Excel export flow chart provided by the present invention. Detailed implementation manners
[0037] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0038] The purpose of the present invention is to provide an Excel import and export method and system based on data monitoring to improve the efficiency of Excel file import and export by being compatible with different data types.
[0039] To make the above objects, features, and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific implementation manners.
[0040] Easy Excel is a simple and memory-saving tool for reading and writing Excel based on Java. It can read a 75M (460,000 rows and 25 columns) Excel within 1 minute with 64M of memory. Using this tool, it can be further encapsulated upward as a general-purpose Excel for reading and writing. Each different Excel file is marked with a file type, using numerical types. At the same time, corresponding models are established for the content of each different Excel file, so that the import and export of different Excel files can be achieved only by simply configuring the file type and establishing the model, realizing function reuse, with non-redundant coding, saving server memory, and shortening the import and export time.
[0041] As Figure 1 shown, an Excel import and export method based on data monitoring provided by the present invention includes:
[0042] Step 101: Obtain the byte input and output streams and row data of the file to be processed; the byte input and output streams include a byte input stream and a byte output stream; the row data includes import row data and export row data.
[0043] Step 102: Construct a data model based on the row data; the data model is the mapping relationship between the file to be processed and the database fields, and its construction process is to create a table with consistent fields in the database according to the header fields in the Excel file, and then establish a class with consistent attributes in the system program. The class here is the data model.
[0044] Step 103: Determine the Class bytecode of the file to be processed according to the data model. The Class bytecode is obtained through the data model class. For example, if User is the data model, then User.class is the Class bytecode.
[0045] Step 104: Perform import and export processing according to the byte input-output stream, the data model, the Class bytecode, and the listener.
[0046] In practical applications, Step 104 specifically includes:
[0047] When the file to be processed is an import file, read according to the byte input stream, the data model, the Class bytecode, and the listener to obtain the file to be imported into the database. Among them, when the file to be processed is an import file, read according to the byte input stream, the data model, the Class bytecode, and the listener to obtain the file to be imported into the database, specifically including:
[0048] Take the byte input stream, the Class bytecode, and the listener as input parameters, and use the excel read builder to build a read workbook.
[0049] Perform SAX parsing according to the read workbook and the data model to obtain the file to be imported into the database.
[0050] In practical applications, before taking the byte input stream, the Class bytecode, and the listener as input parameters and using the excel read builder to build a read workbook, it also includes: judging whether the excel file reader in the initialization environment is initialized successfully; if so, take the byte input stream, the Class bytecode, and the listener as input parameters and use the excel read builder to build a read workbook; if not, interrupt the program.
[0051] When the file to be processed is an export file, write according to the byte output stream, the data model, the Class bytecode, and the listener to obtain an excel file.
[0052] For Excel import processing, the previously popular component in the industry was Apache POI. When parsing Excel, POI reads and loads all data into memory at once, resulting in serious problems during the import process, such as consuming a large amount of memory. Especially when dealing with a large amount of data, the speed is slow and exceptions often occur. It can support a small number of concurrent requests, but once the concurrency increases, there will be an OutOfMemoryError (OOM). Using EasyExcel can solve the technical bottlenecks encountered in the above process. The main technical means it uses is the observer (listener). It reads data line by line from the disk and parses it line by line. It puts a configured number of lines of data into a batch process. When the batch process condition is met, it executes an import of the data once, then clears the data in the batch process, and continues to put the remaining data into the batch process, repeating the above steps. For the Excel import and export process, it achieves general adaptability. For example, if there are two different data types (user data, user's department data) that need to be imported and exported, the traditional approach is to have a set of import and export logic processing for each different data type. If a new data type (user permission data) needs to be added later, another set of import and export logic needs to be added. This will result in a large amount of maintenance work for developers who take over later for a simple Excel import and export function. The general adaptability means that for any data type that needs to be imported and exported, developers only need to add a new type according to the configured general rules.
[0053] The following takes the import and export of user data as an example to illustrate the general rules:
[0054] Assign a numeric type (such as: 1) to the data type of user data. Clearly define the method name for importing user data into the database as: saveUser. Clearly define the method name for querying when exporting user data as: selectPage. Clearly define the interface used for importing and exporting data as: UserMapper. Clearly define the user data model for importing and exporting as User, and the bytecode of the header class as User.class (hereinafter referred to as Class bytecode). The process of establishing the user data model is to abstract the data model using the common attributes and behaviors of users:
[0055] Common attributes: user name, age, gender, ID card, education level, residential address, etc. Common behaviors: eating, sleeping, walking, working, etc. The code mapped to the data model is:
[0056]
[0057]
[0058] Obtain the Class bytecode of the user data model: directly use the model name User.class as the Class bytecode, where the dot "." can be understood as "of", and it is literally translated as "the class of User". Clearly define the channel rules rule for the import and export processing logics. Pass the above six parameters to the User enumeration class. When the user uses the import and export function, match the incoming data type with the determined data type value, and finally find the specific import and export logic for this type of data to complete the final function.
[0059] The specific import solution is as Figure 2 shown:
[0060] First, obtain the byte input stream of the import file. The input is the file file, and the byte input stream is one of the parameters of the reading method.
[0061] Establish the data model corresponding to the import row data. The purpose of using the data model is to clearly abstract the mapping relationship between the imported data attributes and the database table fields one by one. The data model can be understood as the abstraction of a certain type of thing in the real world. By analogy with humans, humans have characteristics such as name, age, gender, ID number, education level, address, etc., and behaviors such as eating, sleeping, walking, working, etc. Abstracted into the Java world, it is actually the class Class, the characteristics are the attributes of the Class, and the behaviors are the methods of the Class. Humans are the abstraction of a specific person, and a specific person is the concretization of humans. Set the attribute names in the model to be the same as the database field names to form a one-to-one mapping relationship.
[0062] Based on the data model, obtain the Class bytecode of the data model. The input for obtaining the bytecode is the data model, and the output is the Class bytecode.
[0063] After the above parameter conditions are prepared, create a general import listener. The listener requires three parameters. Respectively: the public service class for importing data, the Class bytecode of the data model, and the name of the data import interface embedded in the public service class. The public service class is used to process the import of various data types, that is, the data storage process; the Class bytecode is used to reflect and generate model entity objects to store the row data in the excel into the corresponding attributes of the entity object. For example, if the header column name in the excel is name, then set the value of a certain row in the name column to the name attribute of the entity object; the data import interface is used to actually save the data to the database. Pass these three parameters to the listener as constructor parameters. Among them, the import listener used is an existing one.
[0064] Principle of the import listener: The read method of EasyExcel is used to read the data in the Excel row by row. This listener inherits from AnalysisEventListener in Easy Excel. The user customizes the unimplemented method invoke in AnalysisEventListener. Since the data is read row by row, in the invoke method, the data is added to a list one by one, and the number of data is judged at the same time. When the number of data in the list is greater than or equal to the configured batch data number, a data storage operation is performed. The data storage operation uses reflection technology to call the data import interface in the embedded common service class to implement. After this storage operation is completed, the list is cleared and the remaining data storage is continued. During the storage process, if the data in the database field is numeric (123), but the data in the Excel cell is a combination of numbers and letters (123abc), an error will occur during the import. At this time, the custom onException method listens to the errors that occur during the import process and converts the error information into information that non-professionals can understand and presents it. Then the user can check and modify the errors in the Excel file being imported according to the error information, and re-import after completion. Finally, the doAfterAllAnalysed method in the listener does the follow-up work, such as releasing some resources occupied by the program during the import process, etc. This function can be flexibly used.
[0065] The import listener is mainly used to monitor the import process and can configure the number of imported data per batch. Using this listener can effectively handle the OOM caused by the import of large amounts of Excel data and effectively prevent it compared to POI.
[0066] When the basic parameter file byte input stream, Class bytecode, and import listener on which the read method depends are prepared, they are passed to the read method of Easy Excel as input parameters and executed to complete the import process. There is no actual output during the whole process, and the data is finally stored in the database.
[0067] Read method and the principle of executing doRead:
[0068] read method: Take the byte input stream of the imported file, the Class bytecode, and the read listener as input parameters, return an ExcelReaderBuilder (Excel read builder), and save the settings of the three parameters into the property ReadWorkbook (read workbook, which can be understood as an excel object) of the ExcelReaderBuilder. The ExcelReaderBuilder calls the sheet(Object...args) method, passing in sheetNo (worksheet number) and sheetName (worksheet name), indicating reading by page. Use ReadWorkbook as a property to construct and generate an ExcelReader object to create an ExcelReaderSheetBuilder (Excel read worksheet builder), and at the same time add and return sheetNo and sheetName to the ExcelReaderSheetBuilder. The actual values of sheetNo and sheetName are set in ReadSheet. When initializing the ExcelReader object, first select different excel analyzers, including XLS and XLSX. The selection logic is to match the excelType value in ReadWorkbook to create a SAX analyzer XlsSaxAnalyser or XlsxSaxAnalyser (the SAX parsing mode is faster and more efficient. It scans the file line by line and parses while scanning. Compared with the other mode, DOM parsing, SAX parsing can stop at any time during document parsing). At the same time, initialize the AnalysisContextImpl (analyzer global context object), and assign ReadWorkbook to its property ReadWorkbookHolder (read workbook owner) to read the properties passed in ReadWorkbook. The above is the initialization and creation environment.
[0069] doRead Reading Principle: First, check whether ExcelReader in the initialization environment is successfully initialized. If not, interrupt the program; otherwise, use ExcelReader to call the read method with the ReadSheet in the initialization environment as the input parameter. Then use ExcelAnalyser to call the analysis method to perform reading according to the excelReadExecutor selected when creating the environment. Internally, it further calls the execute method of the encapsulated excelReadExecutor to read each page. Internally, it calls the parseXmlSource method to read the data of each page, with the input parameters being the byte input stream InputStream and the content handler ContentHandler. After reading a sheet, call the DefaultAnalysisEventProcessor (default analysis event processor) to read each row of data in the sheet. Immediately afterwards, call the dealData() method to process each row of data. When a row of data is read, the invoke method of the listener will be called in this scope to process the row of data, and then the next row will be read. After processing each row of data, enter the endSheet() method to loop and call the doAfterAllAnalysed method of the custom listener to do post-processing work, such as releasing the resources occupied by the program as mentioned above.
[0070] The specific export solution is as Figure 3 shown:
[0071] First, obtain the byte output stream of the exported file. The input is response, and the output is OutputStream.
[0072] Establish a data model corresponding to the exported row data and obtain the Class bytecode of the data model. The steps for establishing the data model are the same as those for establishing the model in the import process.
[0073] Obtain the data set of the data type to be exported. Since the data is ultimately stored in the database, the data set is obtained by querying the database. There is no input, and the output is the set of all data of the data type to be exported.
[0074] Pass the byte output stream and Class bytecode to the write method of EasyExcel as input parameters to first generate an Excel temporary file, then call the doWrite method, pass in the dataset as the input parameter of the doWrite method to write the data into the Excel file, and the export process ends here. The output is the generated Excel file. Using the EasyExcel.write(Oject...args) method can save the complicated encoding process, and the core export process is handled by the underlying EasyExcel layer, so that the encoding is not redundant, and other types of data can be efficiently developed for export.
[0075] The principle of data writing of doWrite method:
[0076] The write operation is similar to the read operation. The actual write operation is performed by doWrite. First, it is determined whether the excelWriter object for writing data exists. If not, the program throws an exception and interrupts. If so, the write method of excelWriter is called.
[0077] The write method passes two parameters, the first is the data set, and the second is the sheet to be written. The format is write(dataList, writeSheet). This method is actually a wrapper call to the addContent method of ExcelBuilder (the name means adding data), which is added by excelBuilder (excel builder).
[0078] Call the addContent method of ExcelBuilder. In this method, first determine whether dataList exists. If so, add the worksheet object to be written to the context of data writing. Then determine whether excelWriteAddExecutor exists. If not, use the context object as a property to create the object. Use its core add method to traverse the data collection to be exported, and use addOneRowOfDataToExcel to abstract the add method.
[0079] First prepare to create an Excel row, including some attribute processors for the row.
[0080] Enter addJavaObjectToExcel and execute the addJavaObjectToExcel method in excelWriteAddExecutor. The data is parsed here, and the data is parsed into titles and contents, and encapsulated into CellData suitable for Excel format, data type, etc. After this step is completed, the generation of the file stream cannot be seen.
[0081] After the above steps are completed, the finish() method needs to be called using excelWriter, which will output the content stream held by the Excel writer, and the data will be truly written to the file. After that, the stream is closed and the temporary file is deleted.
[0082] The present invention also provides an Excel import and export system based on data monitoring, including:
[0083] An acquisition module for acquiring the byte input and output streams and row data of the file to be processed; the byte input and output streams include a byte input stream and a byte output stream; the row data includes import row data and export row data.
[0084] A construction module for constructing a data model according to the row data; the data model is the mapping relationship between the file to be processed and the database fields.
[0085] A Class bytecode determination module for determining the Class bytecode of the file to be processed according to the data model.
[0086] An import and export processing module for performing import and export processing according to the byte input and output streams, the data model, the Class bytecode, and the listener.
[0087] As an optional implementation manner, the import and export processing module specifically includes:
[0088] An import module for reading according to the byte input stream, the data model, the Class bytecode, and the listener when the file to be processed is an import file, to obtain a file for importing into the database.
[0089] An export module for writing according to the byte output stream, the data model, the Class bytecode, and the listener when the file to be processed is an export file, to obtain an Excel file.
[0090] As an optional implementation manner, the import module specifically includes:
[0091] A construction unit for using the byte input stream, the Class bytecode, and the listener as input parameters to construct a read workbook using an Excel read builder;
[0092] An analysis unit for performing SAX analysis according to the read workbook and the data model to obtain a file for importing into the database.
[0093] As an optional implementation manner, it further includes:
[0094] The judgment module is used to judge whether the excel file reader in the initialization environment is initialized successfully; if so, the byte input stream, the Class bytecode and the listener are used as input parameters, and the excel reading builder is used to build a reading workbook; if not, the program is interrupted.
[0095] After using EasyExcel, the time of Excel import process can be greatly shortened and memory usage can be reduced. The main reason for greatly reducing memory usage is that when parsing Excel, the file data is not loaded into the memory all at once, but the data is read from the disk line by line, parsed one by one, and the parsing mode is adopted. The parsing result of a line is notified and processed in the observer (listener) mode, which supports reading and writing hundreds of MB of Excel while saving memory as much as possible. Because of the handling of exceptions in the import process, the developer can convert it according to different error messages in a targeted manner, and can prompt users in a friendly manner about errors that occur during the process. The technical support behind it comes from the observer (listener) of the tool. The time consumption problem needs to be verified using a large-capacity Excel file.
[0096] This system combines the reading and writing operations of Easy Excel. Taking into account that different data types will be imported and exported, the enumeration strategy mode is used in the coding to achieve dynamic switching of data types and dynamic adaptation.
[0097] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0098] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. An Excel import and export method based on data monitoring, characterized in that, it includes: Obtain the byte input and output stream and row data of the file to be processed; The byte input and output stream includes a byte input stream and a byte output stream; The row data includes imported row data and exported row data; Construct a data model according to the row data; the data model is the mapping relationship between the file to be processed and the database fields; The data model adopts an enumeration strategy pattern; Determine the Class bytecode of the file to be processed according to the data model; Perform import and export processing according to the byte input and output stream, the data model, the Class bytecode and the listener; When the file to be processed is an import file, read according to the byte input stream, the data model, the Class bytecode and the listener to obtain the file imported into the database; use the byte input stream, the Class bytecode and the listener as input parameters, and use the Excel read builder to build a read workbook; perform SAX parsing according to the read workbook and the data model to obtain the file imported into the database; the SAX analyzer is XlsSaxAnalyser or XlsxSaxAnalyser; when the file to be processed is an export file, write according to the byte output stream, the data model, the Class bytecode and the listener to obtain an Excel file; Pass the byte output stream and Class bytecode to the write method of Easy Excel as input parameters to generate an Excel temporary file first, and then call the doWrite method, and pass the data set as the input parameter of the doWrite method to implement data writing into the Excel file; The listener is used to monitor errors occurring during the import process and present the error information in a form that can be understood by non-professionals.
2. The Excel import and export method based on data monitoring according to claim 1, characterized in that, Before using the byte input stream, the Class bytecode and the listener as input parameters and using the Excel read builder to build a read workbook, it further includes: Judge whether the Excel file reader in the initialization environment is initialized successfully; if so, use the byte input stream, the Class bytecode and the listener as input parameters, and use the Excel read builder to build a read workbook; if not, interrupt the program.
3. An Excel import and export system based on data monitoring, characterized in that, it includes: An acquisition module for acquiring the byte input and output stream and row data of the file to be processed; The byte input and output stream includes a byte input stream and a byte output stream; The row data includes imported row data and exported row data; A construction module for constructing a data model according to the row data; the data model is the mapping relationship between the file to be processed and the database fields; The data model adopts an enumeration strategy pattern; The Class bytecode determination module is used to determine the Class bytecode of the file to be processed according to the data model; The import and export processing module is used to perform import and export processing according to the byte input / output stream, the data model, the Class bytecode, and the listener; The import and export processing module specifically includes: an import module, which is used to read according to the byte input stream, the data model, the Class bytecode, and the listener when the file to be processed is an import file, so as to obtain the file for importing into the database; an export module, which is used to write according to the byte output stream, the data model, the Class bytecode, and the listener when the file to be processed is an export file, so as to obtain an excel file; the byte output stream and the Class bytecode are passed to the write method of EasyExcel as input parameters to first generate an excel temporary file, and then the doWrite method is called, and a data set is passed as the input parameter of the doWrite method to implement data writing into the excel file; the import module specifically includes: a construction unit, which is used to use the excel read builder to construct a read workbook with the byte input stream, the Class bytecode, and the listener as input parameters; a parsing unit, which is used to perform SAX parsing according to the read workbook and the data model to obtain the file for importing into the database; the SAX analyzer is XlsSaxAnalyser or XlsxSaxAnalyser; The import and export processing module is also used to listen for errors occurring during the import process according to the listener and present the error information in a form that can be understood by non-professionals.
4. The excel import and export system based on data listening according to claim 3, wherein, it further includes: a judgment module, which is used to judge whether the excel file reader in the initialization environment is successfully initialized; if so, use the excel read builder to construct a read workbook with the byte input stream, the Class bytecode, and the listener as input parameters; if not, interrupt the program.