Method, device, electronic device and storage medium for creating a table in a document
By using the insertion set to generate a form in the document template, the problem of cumbersome table generation process in the existing technologies is solved, and the effect of rapid and simply generating dynamic tables is achieved.
Patent Information
- Application Number
- CN202111629681.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2041-12-28
AI Technical Summary
The prior art has cumbersome configuration processes when generating complex tables, making it difficult to generate tables dynamically based on data quickly and easily.
By obtaining the table in the document template, the insertion set is used to generate multiple table lines, and directly contains the table in the document template to avoid creating XML documents and inserting the cycle logic command to achieve the generation of dynamic tables.
This method simplifies the formation process of the form, improves the simpleness of the operation, eliminates the configuration error, and can accurately generate a dynamic table.
Smart Images

Figure CN114282501B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of document processing, and in particular, to a method, device, electronic device and computer-readable storage medium for creating a table in a document. Background Art
[0002] Currently, there are several ways to generate complex tables in Office software: Method 1:
[0003] Use Word or Excel software to create a standard Word or Excel document; insert a table in the Word or Excel document, insert variables in the dynamic row cells, and save it as a Word XML or Excel XML document as a text template; edit the text template with an XML tool, find the dynamic row information of the table, and embed loop logic commands in its upper and lower positions; write code to read the text template; write code to execute loop logic commands, loop and copy the dynamic row information, and replace the variables in the cell information with actual data; write code to generate a new Word XML or Excel XML document. The defect of this method is that it cannot use a standard Word or Excel document to make a template, but it is necessary to save the standard Word or Excel document as a Word XML document and then make it into a text template. To insert a loop logic command in the text template, it is necessary to edit the text template with an XML tool, find the dynamic row information of the table, embed the loop logic command in its upper and lower positions, and write code to parse the command to execute the loop logic to copy the dynamic row information. Method 2: Use Word or PowerPoint software to create a standard Word or PowerPoint document; use Word or PowerPoint software to edit the Word or PowerPoint document, insert a table into the Word or PowerPoint document and design the content and style, set the mark in the corresponding cell, save the Word or PowerPoint document and make it into a Word or PowerPoint template; write code to call the Office underlying API to read the table in the Word or PowerPoint template; write code to set the marked cell in the table to the actual required content; write code to save the Word or PowerPoint document. The defect of this method is that the style of the table can only be designed when making a Word or PowerPoint template, and the content of the cell can be replaced on this basis, but it is impossible to dynamically generate a dynamic table with the corresponding number of rows according to the data. Method 3: Create a text configuration file; configure the data source parameters in the configuration file; configure the target Excel cell position parameters filled in the data source in the configuration file; configure the style parameters of the corresponding Excel cell in the configuration file; write code to parse the configuration file; write code to call the Office underlying API to generate an Excel document according to the configuration file requirements. The defect of this method is that the configuration process is cumbersome, troublesome and error-prone; it does not support dynamic tables, the configuration is fixed, and only Excel tables of fixed size can be generated, and dynamic Excel tables cannot be generated.Method 4: Use Excel software to create a standard Excel document; use Excel software to edit the Excel document, design a table in the worksheet of the Excel document, insert loop logic commands and variables in the cells of the dynamic rows of the table, save the Excel document and make it into an Excel template; write code to call the Office underlying API to read the table in the Excel template; write code to parse and execute the loop commands in the table, copy the dynamic row information, and use the actual data to provide the variables in the cell; write code to save the Excel document. The drawback of this method is that when designing the Excel template, insert the loop logic command in the dynamic row of the Excel table, and write code to parse the command to execute the loop logic and copy the dynamic row information. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a method, device, electronic device and computer-readable storage medium for creating a table in a document, which can avoid cumbersome configuration and quickly and easily generate a table in a document.
[0005] In a first aspect, an embodiment of the present application provides a method for creating a table in a document, the method comprising:
[0006] Obtain a document template, wherein the document template includes a table, the table includes a template row, and the template row is provided with a collection variable;
[0007] Obtain the underlying storage text of the document template;
[0008] Get the inserted collection;
[0009] A plurality of table rows are generated in the document template according to the insertion set and the underlying stored text to obtain a template table.
[0010] In the above implementation process, a document template is obtained, the document template includes a table, a template row is set in the table, and a collection variable is set in the template row, and the underlying storage text of the document template is obtained; an insert collection is obtained; and multiple table rows are generated in the document template according to the insert collection and the underlying storage text to obtain a template table. Since the table is directly included in the document template, there is no need to create an XML document or insert a loop logic command in the XML template. The table is generated according to the insert collection, so a dynamic table can be generated. Including the table directly in the document template saves a lot of configuration steps, so there is no need to insert a logic loop command in the document, and there is no need to rewrite the code parsing command, which improves the ease of operation.
[0011] Furthermore, the step of generating a plurality of table rows in the document template according to the insertion set and the underlying stored text includes:
[0012] Copy the template row to obtain the current table row;
[0013] According to the index of the current table row in the table row generated by the copy, obtaining the insertion content of the current table row in the insertion set;
[0014] Obtaining the insertion content of the cell in the insertion set according to the collection variable of the cell in the current table row;
[0015] Replace the collection variable of the cell with the inserted content of the cell;
[0016] Repeat the above steps according to the length of the insertion set to obtain the multiple table rows;
[0017] The plurality of table rows are inserted into the underlying storage context.
[0018] In the above implementation process, the template row is directly copied to obtain the current table row. Since a collection variable is inserted into the template row, the generated current table row also has a collection variable. According to the index of the current table row in the copied table row, the inserted content of the current table row is obtained in the insert set. According to the length of the insert set, the above steps are repeated to obtain multiple table rows. It can be seen that the number of table rows is determined by the length of the insert set. Based on this implementation, the length and content of the table can be customized according to the length of the inserted table.
[0019] Further, after the step of inserting the plurality of table rows into the underlying storage text, the method further includes:
[0020] inserting the plurality of table rows below the template rows in the underlying storage context;
[0021] Delete the template line in question.
[0022] In the above implementation process, multiple tables are inserted below the template row in the underlying storage text, and then the template row is deleted, and the content in the table data only remains the content in the inserted set. Based on this implementation, the content in the inserted set can be arranged in the table in an orderly manner, without the need to insert instructions in the template or complicated configuration process, which improves the simplicity of user operation, eliminates configuration errors, and accurately generates tables.
[0023] Further, after the step of inserting the plurality of table rows below the template row in the underlying storage text, the method further includes:
[0024] Get the cell with the merge flag;
[0025] The cells having the merge identifier are merged.
[0026] In the above implementation process, considering that in some cases, tables need to be merged, a merge flag can be added to cells that need to be merged when creating a table, and after generating multiple table rows, the cells with the merge flag are merged.
[0027] Furthermore, the step of obtaining the document template includes:
[0028] Create standard Office documents;
[0029] Inserting the table into the standard Office document;
[0030] Inserting the template row into the table, and inserting the collection variable into a cell in the template row;
[0031] The standard Office document is saved.
[0032] In the above implementation process, a standard Office document is created; a table is inserted into the standard Office document; a template row is inserted into the table, and a collection variable is inserted into the cell in the template row; and the standard Office document is saved. The above entire process does not involve complicated operations, and professional computer knowledge is not required to complete the creation of the document template, which is convenient for ordinary users to use and improves the convenience of user operation. There is no need to insert instructions into the Office document, and no configuration file is required, which improves the speed of creating templates.
[0033] Furthermore, the step of merging the cells with the merging identifiers includes:
[0034] The cells with the merging identifiers are merged using a recursive algorithm.
[0035] In the above implementation process, the core of the recursive algorithm is to split a large task into multiple small tasks. Based on the orderly structure of the generated multiple table rows, the entire table can be merged quickly.
[0036] Furthermore, the step of obtaining the underlying storage text of the document template includes:
[0037] The underlying storage text is obtained through the underlying API of the Office software.
[0038] In the above implementation process, the underlying API has been configured. Compared with the rewritten API, the underlying API of Office software has higher security and fewer vulnerabilities, which can improve the success rate of creation.
[0039] In a second aspect, an embodiment of the present application provides a device for creating a table in a document, comprising:
[0040] A template acquisition module, used to acquire a document template, wherein the document template includes a table, the table includes a template row, and the template row is provided with a collection variable;
[0041] A storage text acquisition module, used to acquire the underlying storage text of the document template;
[0042] Insertion set acquisition module, used to acquire the insertion set;
[0043] The template table generation module is used to generate a plurality of table rows in the document template according to the insertion set and the underlying stored text to obtain a template table.
[0044] In the above implementation process, a document template is obtained, the document template includes a table, a template row is set in the table, and a collection variable is set in the template row, and the underlying storage text of the document template is obtained; an insert collection is obtained; and multiple table rows are generated in the document template according to the insert collection and the underlying storage text to obtain a template table. Since the table is directly included in the document template, there is no need to create an XML document or insert a loop logic command in the XML template. The table is generated according to the insert collection, so a dynamic table can be generated. Including the table directly in the document template saves a lot of configuration steps, so there is no need to insert a logic loop command in the document, and there is no need to rewrite the code parsing command, which improves the ease of operation.
[0045] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any one of the first aspects when executing the computer program.
[0046] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which instructions are stored. When the instructions are executed on a computer, the computer executes the method as described in any one of the first aspects.
[0047] Other features and advantages disclosed in the present application will be described in the following description, or some features and advantages can be inferred or determined without doubt from the description, or can be learned by implementing the above-mentioned technology disclosed in the present application.
[0048] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0050] Figure 1 A flowchart of a method for creating a table in a document provided in an embodiment of the present application;
[0051] Figure 2 A schematic diagram of a process for generating multiple table rows provided in an embodiment of the present application;
[0052] Figure 3 A schematic diagram of a table provided for an embodiment of the present application;
[0053] Figure 4 A schematic diagram of a template table provided for an embodiment of the present application;
[0054] Figure 5 A schematic diagram of the structure of an apparatus for creating a table in a document provided in an embodiment of the present application;
[0055] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0057] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0058] Example 1
[0059] See also Figure 1 , an embodiment of the present application provides a method for creating a table in a document, the method comprising:
[0060] S1: Obtain a document template, the document template includes a table, the table includes a template row, and the template row is set with a collection variable;
[0061] S2: Get the underlying storage text of the document template;
[0062] S3: Get the insert collection;
[0063] S4: Generate multiple table rows in the document template according to the insertion set and the underlying storage text to obtain a template table.
[0064] In the embodiment of the present application, the document template includes a Word document, a PowerPoint document, and an Excel document.
[0065] In the above implementation process, a document template is obtained, the document template includes a table, a template row is set in the table, and a collection variable is set in the template row, and the underlying storage text of the document template is obtained; an insert collection is obtained; and multiple table rows are generated in the document template according to the insert collection and the underlying storage text to obtain a template table. Since the table is directly included in the document template, there is no need to create an XML document or insert a loop logic command in the XML template. The table is generated according to the insert collection, so a dynamic table can be generated. Including the table directly in the document template saves a lot of configuration steps, so there is no need to insert a logic loop command in the document, and there is no need to rewrite the code parsing command, which improves the ease of operation.
[0066] See also Figure 2 In a possible implementation, S4 includes the following sub-steps:
[0067] S41: copy the template row to obtain the current table row;
[0068] S42: according to the index of the current table row in the table row generated by the copy, obtaining the insert content of the current table row in the insert set;
[0069] S43: Obtain the insertion content of the cell in the insertion set according to the collection variable of the cell in the current table row;
[0070] S44: Replace the collection variable of the cell with the inserted content of the cell;
[0071] S45: Repeat the above steps according to the length of the insertion set to obtain multiple table rows;
[0072] S46: Insert multiple table rows into the underlying storage context.
[0073] In the above embodiment, the template row is directly copied to obtain the current table row. Since a collection variable is inserted into the template row, the generated current table row also has a collection variable. According to the index of the current table row in the copied table row, the inserted content of the current table row is obtained in the insert set. The above steps are repeated according to the length of the insert set to obtain multiple table rows. It can be seen that the number of table rows is determined by the length of the insert set. Based on this implementation, the length and content of the table can be customized according to the length of the inserted table.
[0074] In a possible implementation, after the step of inserting multiple table rows into the underlying storage text, the method further includes:
[0075] Insert multiple table rows below the template rows in the underlying storage text;
[0076] Delete the template line.
[0077] In the above implementation process, multiple tables are inserted below the template row in the underlying storage text, and then the template row is deleted, and the content in the table data only remains the content in the inserted set. Based on this implementation, the content in the inserted set can be arranged in the table in an orderly manner, without the need to insert instructions in the template or complicated configuration process, which improves the simplicity of user operation, eliminates configuration errors, and accurately generates tables.
[0078] In a possible implementation, after the step of inserting a plurality of table rows below the template row in the underlying storage text, the method further includes:
[0079] Get the cell with the merge flag;
[0080] Merge cells with merge flags.
[0081] In the above implementation process, considering that in some cases, tables need to be merged, a merge flag can be added to cells that need to be merged when creating a table, and after generating multiple table rows, the cells with the merge flag are merged.
[0082] For example, see Figure 3 , which is a schematic diagram of a template row. The template has a merge identifier ${merge}. After generating multiple tables, the cells with the same content in this column are merged. The effect diagram is as follows Figure 4 shown.
[0083] In a possible implementation, the step of obtaining a document template includes:
[0084] Create standard Office documents;
[0085] Insert tables into standard Office documents;
[0086] Insert a template row into the table, and insert collection variables into the cells in the template row;
[0087] Save standard Office documents.
[0088] In the above implementation process, an Office document is created; a table is inserted into a standard Office document; a template row is inserted into the table, and a collection variable is inserted into a cell in the template row; and a standard Office document is saved. The above entire process does not involve complicated operations, and the creation of a document template can be completed without professional computer knowledge, which is convenient for ordinary users to use and improves the convenience of user operation. There is no need to insert instructions into the Office document, and no configuration file is required, which improves the speed of creating templates.
[0089] In a possible implementation, the step of merging cells with merging identifiers includes:
[0090] Using a recursive algorithm, cells with merge identifiers are merged.
[0091] In the above implementation process, the core of the recursive algorithm is to split a large task into multiple small tasks. Based on the orderly structure of the generated multiple table rows, the entire table can be merged quickly.
[0092] In a possible implementation, the step of obtaining the underlying storage text of the document template includes:
[0093] Get the underlying storage text through the underlying API of Office software.
[0094] In the above implementation process, the underlying API has been configured. Compared with the rewritten API, the underlying API of Office software has higher security and fewer vulnerabilities, which can improve the success rate of creation.
[0095] Example 2
[0096] See also Figure 5 , an embodiment of the present application provides a device for creating a table in a document, comprising:
[0097] The template acquisition module 1 is used to acquire a document template, wherein the document template includes a table, the table includes a template row, and the template row is provided with a collection variable;
[0098] The storage text acquisition module 2 is used to acquire the underlying storage text of the document template;
[0099] Insertion set acquisition module 3, used to acquire the insertion set;
[0100] The template table generation module 4 is used to generate multiple table rows in the document template according to the insertion set and the underlying storage text to obtain a template table.
[0101] In the above implementation process, a document template is obtained, the document template includes a table, the table is provided with a template row, the template row is provided with a collection variable, the underlying storage text of the document template is obtained; an insert collection is obtained; multiple table rows are generated in the document template according to the insert collection and the underlying storage text to obtain a template table. Since the table is directly included in the document template, there is no need to create an XML document or insert a loop logic command in the XML template. The table is generated according to the insert collection, so a dynamic table can be generated. Including the table directly in the document template saves a lot of configuration steps. There is no need to insert a logical loop command in the document, and there is no need to rewrite the code parsing command, which improves the ease of operation.
[0102] In a possible implementation, the template table generation module 4 is also used to copy the template row to obtain the current table row; obtain the insert content of the current table row in the insert set according to the index of the current table row in the copied table row; obtain the insert content of the cell in the insert set according to the collection variable of the cell in the current table row; replace the collection variable of the cell with the insert content of the cell; repeat the above steps according to the length of the insert set to obtain multiple table rows; insert the multiple table rows into the underlying storage text.
[0103] In a possible implementation manner, the template table generation module 4 is further configured to insert a plurality of table rows below the template row in the underlying storage text; and delete the template row.
[0104] In a possible implementation, the device further includes a merging module, configured to obtain cells with a merging identifier; and merge the cells with the merging identifier.
[0105] In a possible implementation, the template acquisition module 1 is used to create a standard Office document; insert a table into the standard Office document; insert a template row into the table, and insert a collection variable into a cell in the template row; and save the standard Office document.
[0106] In a possible implementation, the merging module is used to merge cells with merging identifiers using a recursive algorithm.
[0107] In a possible implementation, the template acquisition module 1 is used to acquire underlying storage text through the underlying API of Office software.
[0108] Example 3
[0109] This application also provides an electronic device, see Figure 6 , Figure 6A block diagram of an electronic device provided in an embodiment of the present application. The electronic device may include a processor 61, a communication interface 62, a memory 63, and at least one communication bus 64. The communication bus 64 is used to realize direct connection and communication between these components. The communication interface 62 of the electronic device in the embodiment of the present application is used to communicate signaling or data with other node devices. The processor 61 may be an integrated circuit chip with signal processing capabilities.
[0110] The processor 61 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor 61 can also be any conventional processor, etc.
[0111] The memory 63 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electric erasable programmable read-only memory (EEPROM), etc. The memory 63 stores computer-readable instructions, and when the computer-readable instructions are executed by the processor 61, the electronic device may execute the various steps involved in the above method embodiment.
[0112] Optionally, the electronic device may further include a storage controller and an input / output unit.
[0113] The memory 63, storage controller, processor 61, peripheral interface, input and output unit components are directly or indirectly electrically connected to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses 64. The processor 61 is used to execute executable modules stored in the memory 63, such as software function modules or computer programs included in the electronic device.
[0114] The input and output unit is used to provide users with the task creation and to create a start optional time period or preset execution time for the task to realize the interaction between the user and the server. The input and output unit can be, but is not limited to, a mouse and a keyboard.
[0115] Understandably, Figure 6 The structure shown is for illustration only. The electronic device may also include Figure 6 More or fewer components as shown, or with Figure 6 Different configurations are shown. Figure 6 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0116] The embodiment of the present application also provides a computer-readable storage medium, on which instructions are stored. When the instructions are run on a computer, the method of the method embodiment is implemented when the computer program is executed by the processor. To avoid repetition, it will not be described here.
[0117] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0118] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0119] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., and other media that can store program codes.
[0120] The above are only embodiments of the present application and are not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0121] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0122] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A method for creating a table in a document, characterized in that: include: Obtain a document template, wherein the document template includes a table, wherein the table includes a template row, and wherein the template row is provided with a collection variable; Obtain the underlying storage text of the document template; Get the inserted collection; Generate multiple table rows in the document template according to the insertion set and the underlying stored text to obtain a template table; The step of obtaining the document template includes: Create standard Office documents; Inserting the table into the standard Office document; Inserting the template row into the table, and inserting the collection variable into a cell in the template row; Saving the standard Office document; The step of generating a plurality of table rows in the document template according to the insertion set and the underlying stored text comprises: Copy the template row to obtain the current table row; According to the index of the current table row in the table row generated by the copy, obtaining the insertion content of the current table row in the insertion set; Obtaining the insertion content of the cell in the insertion set according to the collection variable of the cell in the current table row; Replace the collection variable of the cell with the inserted content of the cell; Repeat the above steps according to the length of the insertion set to obtain the multiple table rows; inserting the plurality of table rows below the template rows in the underlying storage context; Get the cell with the merge flag; Using a recursive algorithm, merging the cells with the merging identifiers; The step of merging the cells with the merging identifiers by using a recursive algorithm includes: Using a recursive algorithm, a large merging task is split into multiple small merging tasks. Based on the orderly structure of the generated multiple table rows, the entire table is merged quickly.
2. The method for creating a table in a document according to claim 1, characterized in that: After the step of inserting the plurality of table rows below the template row in the underlying storage text, the method further comprises: Delete the template line in question.
3. The method for creating a table in a document according to claim 1, characterized in that: The step of obtaining the underlying storage text of the document template includes: The underlying storage text is obtained through the underlying API of the Office software.
4. A device for creating a table in a document, characterized in that: include: A template acquisition module, used to acquire a document template, wherein the document template includes a table, the table includes a template row, and the template row is provided with a collection variable; A storage text acquisition module, used to acquire the underlying storage text of the document template; Insertion set acquisition module, used to acquire the insertion set; A template table generation module, used for generating a plurality of table rows in the document template according to the insertion set and the underlying stored text, to obtain a template table; The template acquisition module is specifically used for: Create standard Office documents; Inserting the table into the standard Office document; Inserting the template row into the table, and inserting the collection variable into a cell in the template row; Saving the standard Office document; The template table generation module is specifically used for: Copy the template row to obtain the current table row; According to the index of the current table row in the table row generated by the copy, obtaining the insertion content of the current table row in the insertion set; Obtaining the insertion content of the cell in the insertion set according to the collection variable of the cell in the current table row; Replace the collection variable of the cell with the inserted content of the cell; Repeat the above steps according to the length of the insertion set to obtain the multiple table rows; inserting the plurality of table rows below the template rows in the underlying storage context; Get the cell with the merge flag; Using a recursive algorithm, merging the cells with the merging identifiers; The step of merging the cells with the merging identifiers by using a recursive algorithm includes: Using a recursive algorithm, a large merging task is split into multiple small merging tasks. Based on the orderly structure of the generated multiple table rows, the entire table is merged quickly.
5. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for creating a table in a document according to any one of claims 1 to 3 is implemented.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a computer, the computer is enabled to execute the method for creating a table in a document according to any one of claims 1 to 3.
Citation Information
Patent Citations
Form automatic generation method and system based on form template set
CN101794280A
Method and device of converting XML document into Excel document
CN101968783A
System and method for quickly customizing and generating excel form, server and medium
CN111046643A