A front-end Excel data analysis, business verification and dynamic mapping import method

By parsing Excel files in the browser to generate standardized two-dimensional matrices and performing business validation, the problems of high server load and delayed error feedback are solved, enabling real-time validation and efficient import of complex reports.

CN123180100APending Publication Date: 2026-11-27CHINA HARBOUR ENGINEERING
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611413640.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-11
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing technologies suffer from problems such as high server load, large network transmission latency, delayed error feedback, inability to verify complex business logic in real time, and inability to handle irregular report structures during the Excel data import process.

Method used

On the browser side, an Excel file is parsed using a front-end spreadsheet parsing library to generate a standardized two-dimensional matrix. This matrix is ​​then used for data organization and business validation, establishing dynamic mapping relationships, converting the data into hierarchical structured objects, and finally rendering and outputting them on the front end.

Benefits of technology

It reduced server load, decreased network transmission overhead, and improved the real-time feedback capability and data processing stability of complex report imports.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123180100A_ABST
    Figure CN123180100A_ABST
Patent Text Reader

Abstract

The embodiment of the application discloses a front-end Excel data analysis, business verification and dynamic mapping import method, the embodiment of the application reads the electronic form file in the browser client, analyzes the worksheet original data and cell coordinate information, generates a standardized two-dimensional matrix in combination with the effective area and the merged cell information; the year, month, amount and other fields in the matrix are subjected to type normalization processing, and the time table header is automatically identified and consistency verified based on the business context; further, the mapping relationship of the source column index, the time dimension and the target hierarchical path is established, and the two-dimensional table data is converted into a structured object for front-end dynamic table rendering. By front-end execution of file analysis, format completion, business verification and hierarchical mapping, the application reduces the server pressure, reduces the network transmission overhead, and improves the real-time feedback capability and data processing stability of complex report import.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer software technology, specifically to a method for importing front-end Excel data parsing, business validation, and dynamic mapping. Background Technology

[0002] As enterprise resource planning (ERP) and customer relationship management (CRM) systems gradually transition from client / server (C / S) architecture to cloud-based microservice architecture (B / S), the batch data import function from Excel faces increasing challenges under the existing technical architecture. Large enterprises and government agencies frequently need to collect and report various statistical data based on Excel in their daily operations. This type of data is characterized by its large volume, diverse statistical definitions, and inconsistent formats. While conventional web applications have good structured data collection capabilities, Excel import remains an irreplaceable and crucial method for collecting large volumes of statistical data. In business scenarios such as annual cash flow forecasting, funding planning, and budget preparation, users need to regularly import large amounts of structured data from Excel spreadsheets into web systems, which places high demands on the efficiency, accuracy, and user experience of data import.

[0003] Currently, mainstream Excel data import solutions still heavily rely on backend servers to handle core processing steps such as data parsing, validation, and database entry. After a user uploads an Excel file through the front-end interface, the file is transmitted over the network to the backend server. The server-side program then uses parsing libraries (such as Apache POI and NPOI) to read the file content, perform data format validation and business rule verification, and finally persist the data to the database. This traditional backend import model has the following technical drawbacks in practical applications:

[0004] Firstly, excessive server load and high network transmission overhead. Excel file parsing, data cleaning, and rule validation are all computationally intensive operations. When the data volume is large or there are many concurrent import requests, the backend server needs to bear a heavy CPU computation load and memory pressure, which can easily lead to slow service response or even crashes. Simultaneously, the original Excel file needs to be uploaded to the server in its entirety, consuming a significant amount of network bandwidth, especially when the file size is large, the network transmission time increases significantly. Furthermore, the data import process is often lengthy, involving multiple queries and validation operations for each data entry, resulting in a persistently high interface response time (TP99), severely impacting user experience.

[0005] Secondly, delayed data error feedback leads to a poor user experience. In the traditional backend import model, issues such as data format errors and business rule conflicts can only be discovered after the file is uploaded to the server and undergoes complete parsing and verification. Users need to wait for the entire round trip—file transfer, server processing, and result return—before they can learn the reason for the import failure and the location of the error. This serial "upload-wait-feedback" model greatly prolongs the data error correction cycle. When erroneous data appears in the middle of the file, users often need to repeatedly modify and re-upload multiple times to complete the import, resulting in a poor interactive experience.

[0006] Third, there is a lack of real-time validation capabilities for complex business contexts. Most existing Excel import validation solutions only check file formats (such as file extensions) or basic data types (such as whether fields are empty or numeric), lacking the ability to perceive and validate business contexts. For example, in an annual budget submission scenario, the system needs to verify whether the year in the imported data matches the current business year, whether the month sequence covers the complete January to December period, and whether the starting month is January. These validation logics, involving the integrity of the time dimension and business consistency, typically require uploading to the server before execution in existing solutions. This not only wastes server resources but also fails to provide users with immediate feedback on format errors and business rule conflicts during the data upload phase.

[0007] Fourth, existing front-end parsing solutions are limited in functionality and struggle to handle complex report structures. In recent years, with the development of front-end technologies, some tools and libraries have emerged for parsing Excel files in the browser (such as SheetJS and read-excel-file), which can read Excel files as two-dimensional arrays or JSON objects. However, most of these solutions only focus on basic data reading and lack the following capabilities: First, they cannot automatically handle irregular table structures in Excel caused by merged cells, empty columns, inconsistent row and column numbers, easily leading to data index misalignment and parsing failures; second, they lack effective support for complex business logic, such as the ability to dynamically identify and group months across multiple years, monitor year changes, and dynamically create parent nodes for hierarchical structure transformations; third, data mapping methods typically use hard-coded column indexes, making it difficult to adapt to report structures that dynamically change across different years and months. Existing front-end parsing solutions are clearly insufficient in terms of data fault tolerance and structuring capabilities when dealing with complex Excel tables, such as cash flow forecast tables, which contain nested structures spanning multiple years and months. Summary of the Invention

[0008] To address this, this invention provides a front-end Excel data parsing, business validation, and dynamic mapping import method to solve the problems of high server load, large network transmission latency, and delayed error feedback caused by the high dependence on the back-end in existing technologies. At the same time, it overcomes the technical problems that existing front-end parsing solutions cannot effectively handle irregular and complex report structures and lack real-time business context validation capabilities.

[0009] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:

[0010] According to a first aspect of the present invention, a method for importing front-end Excel data parsing, business validation, and dynamic mapping is provided, the method comprising:

[0011] File reading: Obtain the Excel file selected by the user through the browser front-end interface, read the Excel file into the browser memory in binary stream form using the browser's native file reading interface, call the front-end spreadsheet parsing library to parse the binary stream into a worksheet object, and convert the worksheet object into a raw two-dimensional array;

[0012] Data regularization: Traverse the original two-dimensional array, calculate the maximum number of columns in all row records, and fill the tail null values ​​of rows with fewer columns than the maximum number of columns with the maximum number of columns to make all rows have the same number of columns, thus generating a standardized two-dimensional matrix;

[0013] Business validation: Extract the year identifier row and month identifier row from the standardized two-dimensional matrix, perform data type validation and business year consistency validation on the year identifier row, and perform time window integrity validation on the month identifier row. If any validation fails, the process is terminated immediately and an error message is returned.

[0014] Dynamic mapping: Traverse the header area of ​​the standardized two-dimensional matrix, monitor the changes in the year values ​​in the year identifier row, and dynamically create a new year parent node whenever a change in the year value is detected. At the same time, establish a mapping relationship between the physical column index and the year-month combination identifier, and store the mapping relationship as a global index mapping table.

[0015] Data mounting: Traverse each data row in the standardized two-dimensional matrix except for the header row, and mount the cell values ​​of each data row in each data column to the month child node under the corresponding year parent node according to the global index mapping table, generating a hierarchical structured data object;

[0016] Rendering output: The hierarchical structured data object is injected into the front-end state management system to drive the front-end table component to complete data rendering.

[0017] Furthermore, the data normalization further includes:

[0018] Iterate through each row of the original two-dimensional array, perform null value detection on the cells in each row, and replace cells with empty or undefined values ​​with empty strings;

[0019] Iterate through each row again, and for rows with a number of columns less than the maximum number of columns, continuously append an empty string to the end of the row in a loop until the number of columns in that row matches the maximum number of columns;

[0020] For each data row whose index is greater than the number of header rows, check if there is a missing index in the data column after the fixed number of header columns. If a missing index is found, automatically assign it the value zero.

[0021] Furthermore, the business verification includes three levels of verification:

[0022] The first level of verification involves traversing the year identifier rows in the standardized two-dimensional matrix and checking whether the value of each year cell is a numeric type. If any cell is a non-numeric type, the format is determined to be incorrect and the process is terminated.

[0023] The second level of verification involves locating the first data year column in the year identifier row after the first level of verification passes, extracting the year value of that column, and comparing the year value with the currently selected business year in the system. If the two are inconsistent, the business year is determined to be mismatched and the process is terminated.

[0024] The third level of verification involves traversing the month identifier rows in the standardized two-dimensional matrix, checking whether the value of the first data month column is the starting month identifier, and checking whether the value of the last data month column is the ending month identifier. If either condition is not met, the time window is determined to be incomplete and the process is terminated.

[0025] Furthermore, the three-level verification adopts an interrupt-first traversal strategy:

[0026] The outer loop iterates through each column in the target verification row, while the inner loop performs verification logic on the cell value of the current column.

[0027] When the inner loop detects any illegal data, it immediately exits the inner loop via a loop interruption statement and sets an error flag.

[0028] The error flag is detected in the outer loop. If the error flag has been set, the outer loop is immediately exited through a loop interruption statement, terminating the entire verification process.

[0029] Furthermore, the dynamic mapping specifically includes:

[0030] Extract the year and month identifier rows from the standardized two-dimensional matrix, skipping the fixed information columns at the beginning of the table header, and only process the data column area;

[0031] Initialize the year cache variable and the node storage array;

[0032] Iterate through each data column in the month identifier row and obtain the current year value from the corresponding column in the year identifier row;

[0033] The current year value is compared with the year cache variable. If the current year value exists and is different from the year cache variable, a new year parent node object is created with the current year value, and the current month value is added as a child node under the year parent node, and the year cache variable is updated.

[0034] If the current year value is consistent with the year cache variable, then the current month value is appended to the child node array under the parent node of the current year;

[0035] The current year value and the current month value are concatenated to form a year-month combination identifier. This year-month combination identifier is then pushed into the global combination key array, and the physical column index counter is incremented synchronously.

[0036] Furthermore, the dynamic mapping also includes tail node cleanup processing:

[0037] After completing the traversal of all data columns, check whether there is a parent node of a year that has been constructed but not yet stored in the global date list in the year cache variable;

[0038] If it exists, push the last year parent node and all its month child nodes into the global date list to complete the construction of the entire hierarchical structure.

[0039] Furthermore, the data mounting specifically includes:

[0040] Traverse each data row in the standardized two-dimensional matrix whose index is greater than the number of header rows, and initialize a blank monthly detail array for each data row;

[0041] Iterate through the data columns in the current data row that are located after the fixed header column, and for each data column, obtain the year and month combination identifier and cell value corresponding to that column;

[0042] A detail object is constructed using the year-month combination identifier and the cell value, and the detail object is sequentially pushed into the month detail array;

[0043] Extract the fixed information columns from the current data row as row identifier fields, combine the month detail array with the row identifier field to form a standardized row data object, and store it in the global table data array.

[0044] Furthermore, data normalization processing is also included after data mounting:

[0045] Traverse the monthly detail array of each standardized row data object in the global table data array, perform type conversion on the numeric fields in each detail object, convert the numeric fields to numeric types, and if the conversion result is an invalid numeric value, set it to null; otherwise, store the converted numeric value again.

[0046] Iterate through the global table data array and remove invalid row records where the row identifier field is empty or missing.

[0047] Furthermore, following the data mounting, business-linked calculations are also included:

[0048] Using the month index as the calculation axis, iterate through the values ​​of each data row in the global table data array for each month;

[0049] Calculate the derived values ​​for each data row column by column. The derived values ​​include at least one of the cumulative value, total value, and year-on-year value.

[0050] The calculated derived values ​​are synchronously updated to the corresponding row data objects.

[0051] Furthermore, the rendering output specifically includes:

[0052] Inject the hierarchical structured data object into the front-end reactive state management library to trigger a state update;

[0053] The front-end table component listens to data changes in the state management library and automatically renders multi-level headers and data cells based on the year parent node and month child node structure in the structured data object.

[0054] During the rendering process, the front-end table component controls the switching of the editable state of the corresponding row cells based on the editing state flags of each data row.

[0055] The embodiments of the present invention have the following advantages:

[0056] This invention reads a spreadsheet file on a browser client, parses the original worksheet data and cell coordinate information, and generates a standardized two-dimensional matrix by combining valid area and merged cell information. It then performs type normalization on fields such as year, month, and amount in the matrix, and automatically identifies and verifies the consistency of the time header based on the business context. Furthermore, it establishes a mapping relationship of "source column index - time dimension - target hierarchical path," converting the two-dimensional table data into a structured object that can be dynamically rendered by the front end. By moving file parsing, format completion, business validation, and hierarchical mapping to the front end, this invention reduces server load, decreases network transmission overhead, and improves the real-time feedback capability and data processing stability of complex report imports. Attached Figure Description

[0057] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely exemplary, and those skilled in the art can derive other embodiments based on the provided drawings without creative effort.

[0058] The structures, proportions, sizes, etc. illustrated in this specification are only for the purpose of assisting those skilled in the art in understanding and reading the content disclosed herein, and are not intended to limit the conditions under which the present invention can be implemented. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in the proportions, or adjustments to the size, without affecting the effects and objectives that the present invention can produce, should still fall within the scope of the technical content disclosed in the present invention.

[0059] Figure 1 This is a flowchart illustrating a front-end Excel data parsing, business validation, and dynamic mapping import method provided in an embodiment of the present invention.

[0060] Figure 2 This is a schematic diagram of the adaptive data completion and alignment process in a front-end Excel data parsing, business validation, and dynamic mapping import method provided in an embodiment of the present invention;

[0061] Figure 3 This is a schematic diagram of the business linkage calculation process in a front-end Excel data parsing, business validation and dynamic mapping import method provided in an embodiment of the present invention. Detailed Implementation

[0062] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0063] refer to Figures 1 to 3 This invention discloses a front-end Excel data parsing, business validation and dynamic mapping import method, including the following steps: File reading: Obtain the Excel file selected by the user through the browser front-end interface, use the browser's native file reading interface to read the Excel file into the browser memory in the form of a binary stream, call the front-end spreadsheet parsing library to parse the binary stream into a worksheet object, and convert the worksheet object into a raw two-dimensional array;

[0064] Data regularization: Traverse the original two-dimensional array, calculate the maximum number of columns in all row records, and fill the tail null values ​​of rows with fewer columns than the maximum number of columns with the maximum number of columns to make all rows have the same number of columns, thus generating a standardized two-dimensional matrix;

[0065] Business validation: Extract the year identifier row and month identifier row from the standardized two-dimensional matrix, perform data type validation and business year consistency validation on the year identifier row, and perform time window integrity validation on the month identifier row. If any validation fails, the process is terminated immediately and an error message is returned.

[0066] Dynamic mapping: Traverse the header area of ​​the standardized two-dimensional matrix, monitor the changes in the year values ​​in the year identifier row, and dynamically create a new year parent node whenever a change in the year value is detected. At the same time, establish a mapping relationship between the physical column index and the year-month combination identifier, and store the mapping relationship as a global index mapping table.

[0067] Data mounting: Traverse each data row in the standardized two-dimensional matrix except for the header row, and mount the cell values ​​of each data row in each data column to the month child node under the corresponding year parent node according to the global index mapping table, generating a hierarchical structured data object;

[0068] Rendering output: The hierarchical structured data object is injected into the front-end state management system to drive the front-end table component to complete data rendering.

[0069] I. File Reading Stage

[0070] Users select files through a hidden file selection control in the browser's front-end interface (i.e. <input type="file">The control (element) selects the Excel file to be imported. The system intercepts the default submit event of this control through an event listener mechanism, obtaining a list of file objects for the user's selected file, event.target.files. If the list of file objects is empty, the system directly terminates the subsequent process without performing any further processing.

[0071] Before reading a new file, the system first performs a front-end state reset operation: clearing the date list dateList and table data tableData stored in memory, and triggering the table component to re-render, ensuring that the data remaining from the previous import operation will not interfere with the current operation.

[0072] Subsequently, the system instantiates a FileReader object natively provided by the browser and calls the object's readAsArrayBuffer(file) method to asynchronously read the user-selected Excel file into the browser's memory as a binary stream. This reading process is executed entirely locally on the client side and does not generate any network data transmission.

[0073] In the onload callback function of the FileReader object, the system obtains the read result e.target.result, which is binary data of type ArrayBuffer. The system encapsulates this binary data into a Uint8Array type, and then calls the XLSX.read(data,{type:'array'}) method of the front-end spreadsheet parsing library (such as the XLSX library) to parse the binary stream into an XLSX Workbook object in the browser's memory.

[0074] The system retrieves the name of the first worksheet from the parsed workbook object, namely workbook.SheetNames[0], and then obtains the corresponding worksheet object workbook.Sheets[sheetName] based on this name. Finally, it calls the XLSX.utils.sheet_to_json(worksheet,{header:1}) method to convert the worksheet object into a raw two-dimensional array (matrix) structure. The parameter header:1 indicates that the first row of the worksheet is used as the header row, generating a pure two-dimensional array format for subsequent data extraction and processing by row and column index.

[0075] II. Data Standardization Stage

[0076] Original two-dimensional arrays in Excel files often present an irregular shape due to the presence of merged cells, empty columns, or inconsistent row and column numbers. To ensure that subsequent value retrieval by column index does not result in out-of-bounds or misalignment anomalies, the system performs adaptive data completion and alignment processing on the original two-dimensional array, specifically including the following sub-steps.

[0077] First sub-step: Calculate the global maximum column width. The system iterates through all rows of the original two-dimensional array, and calculates the maximum number of columns in the entire dataset by aggregating and comparing the actual length of each row (row.length), denoted as maxColumnCount.

[0078] The second sub-step: Null value standardization and replacement. The system iterates through the original two-dimensional array again, performing null value checks on each cell in each row. If a cell is found to have a value of null or undefined, its value is replaced with an empty string to avoid null pointer exceptions in subsequent logic processing.

[0079] The third sub-step: Dynamic padding at the end. The system performs a column count check on each row after null value replacement, determining if the current column count is less than the global maximum column count (maxColumnCount). If the column count is insufficient, an empty string is continuously appended to the end of the row through a loop until the row's column count is exactly the same as the global maximum. After this process, all irregular row data is forcibly converted into a standard matrix structure with a consistent number of columns.

[0080] The fourth sub-step: Default value completion for the numerical range. For the cash flow forecast table business scenario applicable to this embodiment—the first four rows (indexes 0 to 3) are typically the header information area, corresponding to fixed columns such as serial number, code, content, and compilation basis, respectively; from the fifth row (index 4) onwards, the actual numerical data—the system performs secondary completion processing on all data rows with an index greater than 3. Specifically, for each data row with an index greater than 3 (i.e., data columns after the 4th column), if there is no valid index for that column (i.e., the position is missing), the system automatically assigns the value 0 to that position. This processing ensures that subsequent numerical calculations and mappings will not result in non-numeric (NaN) exceptions due to undefined or empty strings, thus guaranteeing the stability of data operations.

[0081] III. Business Verification Phase

[0082] After data normalization, the system activates a multi-level business rule verification engine to perform step-by-step verification of key identifier rows in the standardized two-dimensional matrix. This verification engine employs an optimized traversal strategy of "interruption upon detection," terminating subsequent processing and returning an error message containing precise row coordinates upon detecting any illegal data. This embodiment includes the following three levels of verification.

[0083] Level 1 Validation: Basic Format Validation. The system locates the row with index 2 in the standardized two-dimensional array (i.e., the third row, usually the year identifier row) and scans all columns with indices greater than 3 in this row for data type. The system checks each cell in the year row to see if its value is a numeric type, i.e., it checks if `typeof items !== 'number'`. If any cell's value is found to be non-numeric, the system sets the global formatting flag `isFormat` to `false` and immediately throws an error message "Incorrect format! Year only numbers!" to the front-end interface, terminating all subsequent processing and requiring the user to correct the Excel file and re-import it.

[0084] Second-level verification: Business year consistency verification. After the first-level verification passes, the system enters the business context verification stage. The system traverses the year row at index 2 in the standardized two-dimensional array, locates the column at index 4 (i.e., the first data year column), and extracts the year value of that column. The system performs a strict equality comparison between this year value and the selected business year dataInfo.year in the current business context. If the two are inconsistent, the system immediately throws an error message "The data imported for the project year should be data from January to December of the selected year" and terminates the process. At the same time, during the traversal of the year rows, if the system detects that there is still non-empty data in columns with an index greater than 4 (i.e., there are still year values ​​in subsequent columns besides the first year column), it is determined to be data redundancy or format abnormality, which also triggers the above error message and interrupts the process. This mechanism ensures that the imported data strictly corresponds to a single business year, effectively preventing cross-year data confusion.

[0085] The third level of verification: Time window integrity verification (month sequence continuity verification). The system traverses the row at index 3 (i.e., the fourth row, usually the month identifier row) in the standardized two-dimensional array. First, it checks if the value of the column at index 4 (i.e., the first month column) is "January". If the value at this position is not "January", it indicates that the starting month of the imported data does not meet the business requirements (it must start from January), and the system immediately triggers an error message and interrupts the process. Second, the system continues to check if the value of the column at index 15 (corresponding to the 12th month column) in the month row is "December". If the value at this position is not "December", it indicates that the ending month of the imported data is incomplete or the number of columns is missing, and similarly triggers an error message and interrupts the process.

[0086] The three levels of verification described above are all implemented using a double-loop structure. The outer loop iterates through the target verification row (year or month row), while the inner loop iterates through the key columns within that row. Once invalid data is detected in the inner loop, the system immediately interrupts the inner loop with a `break` statement, then checks the status of the error flag `hasError`. If an error has been flagged, the entire verification process is completely terminated using the `break` statement in the outer loop. This detection-and-interruption strategy avoids consuming computational resources on invalid data, maximizing verification efficiency.

[0087] IV. Dynamic Mapping Stage

[0088] After successful validation, the system executes a dynamic mapping algorithm from flat data to hierarchical objects, converting the regular two-dimensional array into a nested tree-like JSON structure. This stage specifically includes the following sub-steps.

[0089] First sub-step: Header row extraction and initialization. The system extracts the year row (yearList) at index 2 and the month row (monList) at index 3 from a standardized two-dimensional array. These two rows together form the header context for subsequent dynamic mapping. The system also initializes the following temporary variables: obj – to store the year node object currently being constructed; arr – to store the array of month child nodes under the current year; dateStrs – to store the global array of "year + month" composite keys; tempIndex – an auto-incrementing physical column index counter; tempYear – the currently detected year cache value.

[0090] The second sub-step: Year change monitoring and dynamic creation of parent nodes. The system iterates through the month rows (monList), skipping the first four header columns (indexes 0 to 3), and only processes the actual data columns with indices greater than 3. For each data column, the system first extracts the year value (year) from the corresponding column of the year row (yearList). Then, it performs year change detection: comparing the current year value (year) with the cached value (tempYear).

[0091] If the current year value exists and is not equal to the cached value (i.e., a year change is detected), the system performs the following operations: First, it checks whether a complete year node object obj.year already exists in the cache. If it does, it pushes the year node object and its month subarray arr into the global date list dateList. Second, it resets obj and arr, creating a new parent node object obj={year:String(year)} with the current new year value. Third, it pushes the current month value into the new month subarray arr in the format {dateStr:String(item),dateIndex:tempIndex}. Finally, it updates the cached value tempYear=year.

[0092] If the current year value matches the cached value (i.e., it is still within the same year range), the system will directly append the current month value to the current month subarray arr in the same format.

[0093] Regardless of whether the year changes, the system concatenates the current cached year with the current month value to form a composite key (e.g., January 2025), pushes it into the global composite key array dateStrs, and increments the physical column index counter tempIndex by 1.

[0094] The third sub-step: Tail node cleanup. After the traversal is complete, the system pushes the last year node under construction and its month subarray into dateList, completing the construction of the entire nested structure.

[0095] V. Data Mounting Phase

[0096] After dynamic mapping is completed, the system performs data row mapping and structured mounting operations, which include the following sub-steps.

[0097] The first sub-step: Data row traversal and detail array construction. The system traverses all data rows (i.e., actual business data rows) with indices greater than 3 in the standardized two-dimensional array. For each data row, the system initializes an empty `details` array to store the values ​​of all month columns for that row. The system internally traverses all columns of that row, skipping the first four fixed columns (indices 0 to 3), and only processes data columns with indices greater than 3. For each data column, the system creates a detail object `detail={dateStr:dateStrs[i-4],money:String(money)}`, where `i-4` is used to map the current column index to the corresponding position in the global composite key array (because the composite key array does not contain the first four header columns), and `money` is the value of the current cell. The system pushes this detail object sequentially into the `details` array. After the internal traversal is complete, the `details` array contains the complete numerical distribution of that row across all months.

[0098] The second sub-step: Construction of standardized row data objects. The system constructs a standardized row data object rowData={index:index-3,no:item[0],code:item[1],content:item[2],compilationBasis:item[3],details:details,isEdit:false}, where index-3 is the relative row index (counting from 1), no is the serial number column, code is the code column (business primary key), content is the content column, compilationBasis is the compilation basis column, details is the monthly numerical detail array, and isEdit is the edit status flag. The system pushes this object into the global table data array tableData.

[0099] The third sub-step: Data normalization. The system performs the following two normalization operations. First, numeric type normalization: Iterates through the details array of all rows in tableData, and performs normalization on each money field—first converting it to a numeric type Number(res.money). If the conversion result is NaN or Infinity, it is set to an empty string; otherwise, the converted value is converted back to a string type for storage. This step ensures the consistency of the data type for all monetary amounts and eliminates invalid values. Second, invalid row filtering: Performs a filtering operation on tableData, removing all rows where the code field is empty or missing. The code field, as the business primary key, is the core basis for determining whether a row is a valid data row.

[0100] The fourth sub-step: Business-linked calculation. After data mapping and normalization are completed, the system automatically triggers business-linked calculations. These calculations use the monthly index as the axis and employ a loop-driven approach to calculate the derived values ​​for all rows column by column, including but not limited to cumulative values, total values, and year-on-year values, ensuring data consistency and integrity.

[0101] VI. Rendering Output Stage

[0102] The system injects the reorganized hierarchical structured data objects (i.e., the global table data array `tableData` and the global date list `dateList`) into the front-end reactive state management system (such as the Vuex state management library or the Pinia state management library), triggering state updates. The front-end table component listens for data changes in the state management library and automatically renders multi-level headers and data cells based on the year parent node and month child node structure in the structured data objects. During rendering, the front-end table component controls the editing state switching of the corresponding row cells according to the editable state flag `isEdit` of each data row, realizing real-time partial or full update rendering of the data table interface.

[0103] Although the present invention has been described in detail above with general descriptions and specific embodiments, modifications or improvements can be made to it, which will be obvious to those skilled in the art. Therefore, all such modifications or improvements made without departing from the spirit of the present invention fall within the scope of protection claimed by the present invention.

Claims

1. A method for importing front-end Excel data through parsing, business validation, and dynamic mapping, characterized in that: The method includes: File reading: Obtain the Excel file selected by the user through the browser front-end interface, read the Excel file into the browser memory in binary stream form using the browser's native file reading interface, call the front-end spreadsheet parsing library to parse the binary stream into a worksheet object, and convert the worksheet object into a raw two-dimensional array; Data regularization: Traverse the original two-dimensional array, calculate the maximum number of columns in all row records, and fill the tail null values ​​of rows with fewer columns than the maximum number of columns with the maximum number of columns to make all rows have the same number of columns, thus generating a standardized two-dimensional matrix; Business validation: Extract the year identifier row and month identifier row from the standardized two-dimensional matrix, perform data type validation and business year consistency validation on the year identifier row, and perform time window integrity validation on the month identifier row. If any validation fails, the process is terminated immediately and an error message is returned. Dynamic mapping: Traverse the header area of ​​the standardized two-dimensional matrix, monitor the changes in the year values ​​in the year identifier row, and dynamically create a new year parent node whenever a change in the year value is detected. At the same time, establish a mapping relationship between the physical column index and the year-month combination identifier, and store the mapping relationship as a global index mapping table. Data mounting: Traverse each data row in the standardized two-dimensional matrix except for the header row, and mount the cell values ​​of each data row in each data column to the month child node under the corresponding year parent node according to the global index mapping table, generating a hierarchical structured data object; Rendering output: The hierarchical structured data object is injected into the front-end state management system to drive the front-end table component to complete data rendering.

2. The method for importing front-end Excel data parsing, business validation, and dynamic mapping as described in claim 1, characterized in that, The data normalization further includes: Iterate through each row of the original two-dimensional array, perform null value checks on the cells in each row, and replace cells with empty or undefined values ​​with empty strings; Iterate through each row again, and for rows with fewer columns than the maximum number of columns, continuously append an empty string to the end of the row in a loop until the number of columns in that row matches the maximum number of columns. For each data row whose index is greater than the number of header rows, check if there is a missing index in the data column after the fixed number of header columns. If a missing index is found, automatically assign it the value zero.

3. The method for importing front-end Excel data parsing, business validation, and dynamic mapping as described in claim 1, characterized in that, The business verification includes three levels of verification: The first level of verification involves traversing the year identifier rows in the standardized two-dimensional matrix and checking whether the value of each year cell is a numeric type. If any cell is a non-numeric type, the format is determined to be incorrect and the process is terminated. The second level of verification involves locating the first data year column in the year identifier row after the first level of verification passes, extracting the year value of that column, and comparing the year value with the currently selected business year in the system. If the two are inconsistent, the business year is determined to be mismatched and the process is terminated. The third level of verification involves traversing the month identifier rows in the standardized two-dimensional matrix, checking whether the value of the first data month column is the starting month identifier, and checking whether the value of the last data month column is the ending month identifier. If either condition is not met, the time window is determined to be incomplete and the process is terminated.

4. The method for importing front-end Excel data parsing, business validation, and dynamic mapping as described in claim 3, characterized in that, The three-level verification adopts an interrupt-first traversal strategy: The outer loop iterates through each column in the target verification row, while the inner loop performs verification logic on the cell value of the current column. When the inner loop detects any illegal data, it immediately exits the inner loop via a loop interruption statement and sets an error flag. The error flag is detected in the outer loop. If the error flag has been set, the outer loop is immediately exited through a loop interruption statement, terminating the entire verification process.

5. The method for importing front-end Excel data parsing, business validation, and dynamic mapping as described in claim 1, characterized in that, The dynamic mapping specifically includes: Extract the year and month identifier rows from the standardized two-dimensional matrix, skipping the fixed information columns at the beginning of the table header, and only process the data column area; Initialize the year cache variable and the node storage array; Iterate through each data column in the month identifier row and obtain the current year value from the corresponding column in the year identifier row; The current year value is compared with the year cache variable. If the current year value exists and is different from the year cache variable, a new year parent node object is created with the current year value, and the current month value is added as a child node under the year parent node, and the year cache variable is updated. If the current year value is consistent with the year cache variable, then the current month value is appended to the child node array under the parent node of the current year; The current year value and the current month value are concatenated to form a year-month combination identifier. This year-month combination identifier is then pushed into the global combination key array, and the physical column index counter is incremented synchronously.

6. The method for importing front-end Excel data parsing, business validation, and dynamic mapping as described in claim 5, characterized in that, The dynamic mapping also includes tail node cleanup processing: After completing the traversal of all data columns, check whether there is a parent node of a year that has been constructed but not yet stored in the global date list in the year cache variable; If it exists, push the last year parent node and all its month child nodes into the global date list to complete the construction of the entire hierarchical structure.

7. The method for importing front-end Excel data parsing, business validation, and dynamic mapping as described in claim 1, characterized in that, The data mounting specifically includes: Traverse each data row in the standardized two-dimensional matrix whose index is greater than the number of header rows, and initialize a blank monthly detail array for each data row; Iterate through the data columns in the current data row that are located after the fixed header column, and for each data column, obtain the year and month combination identifier and cell value corresponding to that column; A detail object is constructed using the year-month combination identifier and the cell value, and the detail object is sequentially pushed into the month detail array; Extract the fixed information columns from the current data row as row identifier fields, combine the month detail array with the row identifier field to form a standardized row data object, and store it in the global table data array.

8. The method for importing front-end Excel data parsing, business validation, and dynamic mapping as described in claim 7, characterized in that, Data mounting also includes data normalization processing: Traverse the monthly detail array of each standardized row data object in the global table data array, perform type conversion on the numeric fields in each detail object, convert the numeric fields to numeric types, and if the conversion result is an invalid numeric value, set it to null; otherwise, store the converted numeric value again. Iterate through the global table data array and remove invalid row records where the row identifier field is empty or missing.

9. The method for importing front-end Excel data parsing, business validation, and dynamic mapping as described in claim 7, characterized in that, Following the data mounting, business-linked calculations are also included: Using the month index as the calculation axis, iterate through the values ​​of each data row in the global table data array for each month; Calculate the derived values ​​for each data row column by column. The derived values ​​include at least one of the cumulative value, total value, and year-on-year value. The calculated derived values ​​are synchronously updated to the corresponding row data objects.

10. The method for importing front-end Excel data parsing, business validation, and dynamic mapping as described in any one of claims 1 to 9, characterized in that, The rendering output specifically includes: Inject the hierarchical structured data object into the front-end reactive state management library to trigger a state update; The front-end table component listens to data changes in the state management library and automatically renders multi-level headers and data cells based on the year parent node and month child node structure in the structured data object. During the rendering process, the front-end table component controls the switching of the editable state of the corresponding row cells based on the editing state flags of each data row.