A method and apparatus for non-blocking parallel computation of electronic spreadsheet formulas
Patent Information
- Application Number
- CN202610795428.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-04
- Publication Date
- 2026-08-28
- Estimated Expiration
- 2046-06-04
AI Technical Summary
然而,传统电子表格的公式计算多采用整体执行模式,计算过程中界面进程易被占用,用户在公式计算期间无法正常进行编辑、修改等操作,极大影响使用体验
[0015]本申请实施例提供的计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现本申请实施例提供的所述的方法。
Smart Images

Figure CN122332136B_ABST
Abstract
Claims
1. A non-blocking parallel computation method for spreadsheet formulas, characterized in that, The method includes: The main thread retrieves the formula to be calculated from the spreadsheet, performs expression tree parsing, dependency resolution, and adaptation on the formula to be calculated, obtains the formula calculation data, and sends the formula calculation data and the corresponding calculation task to the worker thread through the message queue. The worker thread performs scheduling and planning processing on the calculation task corresponding to the formula to be calculated based on the formula calculation data to obtain an initial formula calculation scheme. The worker thread performs phased calculations on the formula to be calculated based on the initial formula calculation scheme, obtains the formula calculation result and the real-time calculation progress, and sends the formula calculation result and the real-time calculation progress to the main thread through a message queue; the main thread performs table interface rendering and display update processing on the formula calculation result and the real-time calculation progress to obtain the real-time table display data. The main thread performs real-time detection and response processing on user operation events based on the table presentation status corresponding to the real-time data displayed in the table, obtains the operation response result, and sends the operation response result to the worker thread through the message queue; the worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the operation response result to obtain the adapted and adjusted formula calculation scheme. The worker thread performs a full verification of the calculation completion status of the formula to be calculated based on the adapted and adjusted formula calculation scheme to obtain the calculation completion degree. When the calculation completion degree reaches the preset completion threshold, the calculation results of all formulas to be calculated are sent to the main thread through the message queue. The main thread integrates and updates the calculation results of the formulas to be calculated to obtain the target calculation result and the corresponding table display data. The worker thread performs phased calculations on the formula to be calculated based on the initial formula calculation scheme, obtaining the formula calculation result and real-time calculation progress, and sends the formula calculation result and real-time calculation progress to the main thread through a message queue; the main thread performs table interface rendering and display updates on the formula calculation result and real-time calculation progress to obtain real-time table display data, including: The worker thread performs execution timing and calculation unit splitting on the initial formula calculation scheme to obtain multiple calculation stages ordered according to the formula calculation dependency relationship; The worker thread performs dependency validity checks and numerical calculations on the formula to be calculated corresponding to the calculation stage to obtain the formula calculation result of the current calculation stage. The worker thread updates the computational dependencies of the formula to be calculated that depend on the calculation results of the formula in the current calculation stage, and obtains the dependency adjustment data of the corresponding formula to be calculated. The worker thread performs statistical processing on the percentage of completed calculations of the formula to be calculated based on the formula calculation results of the current calculation stage and the dependency adjustment data of the corresponding formula to be calculated, and obtains the real-time calculation progress. The worker thread sends the formula calculation result of the current calculation stage and the real-time calculation progress to the main thread through a message queue. The main thread performs table interface rendering and update processing on the received formula calculation result and real-time calculation progress to obtain the real-time table display data. The phased computation process is executed by worker threads, which execute computation tasks in batches according to preset time slices. After each batch of computation is completed, the worker threads check and process the messages sent by the main thread.
2. The method according to claim 1, characterized in that, The main thread retrieves the formula to be calculated from the spreadsheet, performs expression tree parsing, dependency resolution, and adaptation processing on the formula to obtain the formula calculation data, including: The main thread performs syntax compliance checks and standardized decomposition on the formulas to be calculated in the obtained spreadsheet to obtain the basic data of the formulas; The main thread performs reference association identification and statistical processing on the basic data of the formula to obtain computational dependency data; The main thread performs a verification process on the formula to be calculated to obtain calculation execution adaptation data. The main thread performs structured integration processing on the computation dependency data and the computation execution adaptation data to obtain the formula calculation data.
3. The method according to claim 1, characterized in that, The worker thread performs scheduling and planning processing on the calculation task corresponding to the formula to be calculated based on the formula calculation data, to obtain an initial formula calculation scheme, including: The worker thread sorts the computation dependency data in the formula calculation data by computation priority to obtain the execution timing data of the formula to be calculated; The worker thread performs unit splitting on the calculation task corresponding to the formula to be calculated based on the execution timing data to obtain the calculation execution unit; The worker thread performs execution scenario matching processing on the calculation execution unit and the calculation execution adaptation data in the formula calculation data to obtain the execution adaptation rules; The worker thread performs structured integration processing on the execution timing data, the computation execution unit, and the execution adaptation rules to obtain an initial formula calculation scheme.
4. The method according to claim 1, characterized in that, The main thread performs real-time detection and response processing of user operation events based on the table presentation status corresponding to the real-time data displayed in the table, obtains the operation response result, and sends the operation response result to the worker thread through the message queue. The worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the operation response result to obtain an adapted formula calculation scheme, including: The main thread performs real-time detection and type classification processing on the table presentation status corresponding to the real-time data displayed in the table to obtain categorized user operation data. The main thread performs compliance verification and corresponding response processing on the categorized user operation data to obtain the operation response results; The main thread sends the operation response result to the worker thread through a message queue. The worker thread calculates the impact range and identifies the adjustment requirements of the operation response result to obtain the formula calculation scheme adjustment parameters. The worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the formula calculation scheme adjustment parameters to obtain the adapted and adjusted formula calculation scheme.
5. The method according to claim 1, characterized in that, The worker thread performs a full verification of the calculation completion status of the formula to be calculated based on the adapted and adjusted formula calculation scheme to obtain the calculation completion degree. When the calculation completion degree reaches the preset completion threshold, the calculation results of the full set of formulas to be calculated are sent to the main thread through the message queue. The main thread integrates and updates the calculation results of the formula to be calculated, obtaining the target calculation result and the corresponding table display data, including: The worker thread performs a full verification of the calculation completion status of the formula to be calculated corresponding to the adapted and adjusted formula calculation scheme, and obtains full calculation completion data. The worker thread compares and verifies the full calculation completion data with the preset completion threshold to obtain the calculation completion status matching result. When the calculation completion status matching result reaches the preset completion threshold, the worker thread sends the calculation results of each stage formula corresponding to the formula to be calculated to the main thread through the message queue; The main thread performs consistency verification and integration on the received formula calculation results to obtain the target calculation result. It then performs full table interface rendering and display update processing on the target calculation result to obtain the table display data corresponding to the target calculation result.
6. A non-blocking parallel computing device for spreadsheet formulas, characterized in that, include: The acquisition module is used to acquire the formula to be calculated in the spreadsheet through the main thread, perform expression tree parsing, dependency parsing and adaptation processing on the formula to be calculated to obtain the formula calculation data, and send the formula calculation data and the corresponding calculation task to the worker thread through the message queue. The processing module is used to schedule and plan the calculation tasks corresponding to the formula to be calculated based on the calculation data of the formula through the worker thread, so as to obtain the initial formula calculation scheme. The update module is used to perform phased calculations on the formula to be calculated based on the initial formula calculation scheme through a worker thread, obtain the formula calculation result and the real-time calculation progress, and send the formula calculation result and the real-time calculation progress to the main thread through a message queue; The main thread performs table interface rendering and display updates on the calculation results of the formula and the real-time calculation progress to obtain the real-time table display data. The processing module is also used to detect and respond to user operation events in real time through the main thread based on the table presentation status corresponding to the real-time data displayed in the table, obtain operation response results, and send the operation response results to the worker thread through the message queue; The worker thread dynamically adapts and adjusts the initial formula calculation scheme based on the operation response result to obtain the adapted and adjusted formula calculation scheme. The processing module is further configured to perform a full verification of the calculation completion status of the formula to be calculated based on the adapted and adjusted formula calculation scheme through a worker thread, to obtain the calculation completion degree. When the calculation completion degree reaches a preset completion threshold, the calculation results of the full set of formulas to be calculated are sent to the main thread through a message queue. The main thread integrates and updates the calculation results of the formulas to be calculated to obtain the target calculation result and the corresponding table display data. The processing module is also used for the worker thread to perform phased calculation processing on the formula to be calculated based on the initial formula calculation scheme, to obtain the formula calculation result and the real-time calculation progress, and to send the formula calculation result and the real-time calculation progress to the main thread through a message queue; The main thread performs table interface rendering and display updates on the calculation results of the formula and the real-time calculation progress to obtain the real-time table display data, wherein: The worker thread performs execution timing and calculation unit splitting on the initial formula calculation scheme to obtain multiple calculation stages ordered according to the formula calculation dependency relationship; The worker thread performs dependency validity checks and numerical calculations on the formula to be calculated corresponding to the calculation stage to obtain the formula calculation result of the current calculation stage. The worker thread updates the computational dependencies of the formula to be calculated that depend on the calculation results of the formula in the current calculation stage, and obtains the dependency adjustment data of the corresponding formula to be calculated. The worker thread performs statistical processing on the percentage of completed calculations of the formula to be calculated based on the formula calculation results of the current calculation stage and the dependency adjustment data of the corresponding formula to be calculated, and obtains the real-time calculation progress. The worker thread sends the formula calculation result of the current calculation stage and the real-time calculation progress to the main thread through a message queue. The main thread performs table interface rendering and update processing on the received formula calculation result and real-time calculation progress to obtain the real-time table display data. The phased computation process is executed by worker threads, which execute computation tasks in batches according to preset time slices. After each batch of computation is completed, the worker threads check and process the messages sent by the main thread.
7. A computer device comprising a memory and a processor, the memory storing a computer program executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Spreadsheet formula calculation anti-jamming method, device and equipment and storage medium
CN119129568A
Multi-thread spreadsheet processing with dependency levels
CN101438276A
Task processing method and device, equipment and medium
CN115357361A