Table conversion method, device, computer equipment and storage medium
By obtaining and converting the data content and format properties of the table, generating string arrays and key-value pair arrays, and rendering them to a web page, the problem of inefficient conversion of offline tables to online tables is solved, and efficient and convenient table conversion is achieved.
Patent Information
- Application Number
- CN202010890061.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-28
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2040-08-28
AI Technical Summary
The existing method of converting offline tables into online tables is inefficient and cannot meet the conversion needs of complex tables. Especially online editing requires strong platform support, and there are various restrictions on submitting form data through form forms.
By obtaining the data content and format properties of the table to be converted, applying a preset formal conversion strategy, converting it into a string array and a key-value pair array, and rendering it into a web page to generate a target web page table.
It improves the efficiency and convenience of converting offline tables into online tables, avoids additional restrictions, and realizes efficient conversion of complex tables.
Smart Images

Figure CN112036124B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a table conversion method, apparatus, computer equipment, and storage medium. Background Art
[0002] With the rapid development of the Internet industry, converting electronic documents in complex offline scenarios to online electronic documents has become a new hot topic. For example, there is a high-frequency demand for converting offline forms into online forms.
[0003] There are two main methods for converting offline forms into online ones: creating and editing the form directly online, or submitting the form data through a form. While online form editing is convenient, it requires powerful platform support, which is simply not feasible for a typical online system. Generating forms through form submissions also has various limitations, resulting in low conversion efficiency and an inability to meet the complex needs of converting offline forms.
[0004] Therefore, how to conveniently convert offline forms into online forms and improve the conversion efficiency of forms has become an urgent problem that needs to be solved. Summary of the Invention
[0005] The present application provides a table conversion method, apparatus, computer device and storage medium, which converts the data content and format attributes corresponding to each cell according to a preset format conversion strategy and renders the obtained target data into a web page, thereby improving the efficiency and convenience of converting offline tables to be converted into online web pages.
[0006] In a first aspect, the present application provides a table conversion method, the method comprising:
[0007] Obtaining a table to be converted, and extracting data content and format attributes corresponding to each cell in the table to be converted;
[0008] According to a preset format conversion strategy, the data content and format attributes corresponding to each cell are converted to obtain target data corresponding to the table to be converted, wherein the target data includes a string array and a key-value pair array;
[0009] The string array and key-value pair array in the target data are rendered into a web page to obtain a target web page table corresponding to the table to be converted.
[0010] In a second aspect, the present application further provides a table conversion device, the device comprising:
[0011] A data acquisition module is used to acquire a table to be converted and extract the data content and format attributes corresponding to each cell in the table to be converted;
[0012] a form conversion module, configured to perform form conversion on the data content and format attributes corresponding to each of the cells according to a preset form conversion strategy, to obtain target data corresponding to the table to be converted, wherein the target data includes a string array and a key-value pair array;
[0013] The data rendering module is used to render the string array and key-value pair array in the target data into a web page to obtain a target web page table corresponding to the table to be converted.
[0014] In a third aspect, the present application further provides a computer device, comprising a memory and a processor;
[0015] The memory is used to store computer programs;
[0016] The processor is configured to execute the computer program and implement the above-mentioned table conversion method when executing the computer program.
[0017] In a fourth aspect, the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the table conversion method as described above.
[0018] The present application discloses a table conversion method, apparatus, computer equipment and storage medium. By acquiring a table to be converted, the data content and format attributes corresponding to each cell in the table to be converted can be extracted; by performing form conversion on the data content and format attributes corresponding to each cell according to a preset form conversion strategy, the target data corresponding to the table to be converted can be obtained, thereby realizing form conversion of complex offline tables without additional restrictions; by rendering the string array and key-value pair array in the target data into a web page, the target web page table corresponding to the table to be converted is obtained, thereby improving the efficiency and convenience of converting the offline table to be converted into the online target web page table. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0020] Figure 1 is a schematic flow chart of a table conversion method provided in an embodiment of the present application;
[0021] Figure 2 yes Figure 1 A schematic flow chart of the sub-steps of performing formal conversion on data content and format attributes in ;
[0022] Figure 3 yes Figure 1 A schematic flowchart of the sub-steps of rendering target data to a web page;
[0023] Figure 4 is a schematic flow chart of another table conversion method provided in an embodiment of the present application;
[0024] Figure 5 is a schematic diagram of an input box provided in an embodiment of the present application;
[0025] Figure 6 is a schematic block diagram of a pop-up window provided in an embodiment of the present application;
[0026] Figure 7 It is a schematic diagram of a webpage table to be edited after hiding cells provided in an embodiment of the application;
[0027] Figure 8 A schematic block diagram of a table conversion device provided in an embodiment of the present application;
[0028] Figure 9 A schematic block diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0030] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, combined, or partially merged, so the actual execution order may vary depending on the actual situation.
[0031] It should be understood that the terms used in this specification are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0032] It will also be understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0033] Embodiments of the present application provide a table conversion method, apparatus, computer device, and storage medium. The table conversion method can be applied to a server or terminal to implement a pre-set format conversion strategy, converting the data content and format attributes corresponding to each cell and rendering the resulting target data on a web page. This can improve the efficiency and convenience of converting an offline table to be converted into an online target web page table.
[0034] The server can be an independent server or a server cluster, and the terminal can be an electronic device such as a smart phone, tablet computer, laptop computer, or desktop computer.
[0035] The following describes some embodiments of the present application in detail with reference to the accompanying drawings. In the absence of conflict, the following embodiments and features therein may be combined with each other.
[0036] like Figure 1 As shown, the table conversion method includes steps S10 to S30.
[0037] Step S10: Acquire a table to be converted, and extract data content and format attributes corresponding to each cell in the table to be converted.
[0038] Exemplarily, the backend of the server or terminal includes an upload interface, wherein the upload interface is used to obtain the table to be converted.
[0039] It should be noted that in an embodiment of the present application, the form to be converted can be uploaded to the background of the server or terminal through the upload interface; after the form conversion processing in the background, the target data obtained after processing is rendered to the front-end web page to obtain a web page form.
[0040] In some embodiments, a table uploaded by a user is received through an upload interface, and the uploaded table is used as a table to be converted. The table to be converted may include but is not limited to an Excel table, a Word table, a CSV table, etc. In the embodiment of the present application, the table to be converted is an Excel table for detailed description.
[0041] For example, the table to be converted is shown in Table 1:
[0042] Table 1 is the table to be converted
[0043]
[0044] It should be noted that Table 1 includes header cells and non-header cells; the header cells are distinguished by bold borders.
[0045] Specifically, the data content and format attributes corresponding to each cell in the table to be converted are extracted, and the cells in the table to be converted can be obtained in sequence; then the information in each cell is extracted through an information extraction tool to obtain the data content and format attributes corresponding to the table to be converted.
[0046] Among them, format attributes include parameters such as the cell column width, row width, and whether the cell is a table header.
[0047] Exemplarily, each cell in the table to be converted may be read sequentially from left to right and from top to bottom in a row-column traversal manner.
[0048] For example, the information extraction tool can be the jxl.jar tool. It should be noted that the jxl.jar tool is a Java-based library for manipulating Excel spreadsheets. It can create, read, and modify Excel spreadsheets, format data, and perform cell operations.
[0049] Specifically, the jxl.jar tool is used to extract the data content and format attributes corresponding to the first cell in the table to be converted. The obtained data content is "Test Header 0" and the format attributes are "column width is 2, row width is 2, header". For example, the jxl.jar tool is used to extract the data content and format attributes corresponding to the second cell in the table to be converted. The obtained data content is "Test Header 1" and the format attributes are "column width is 2, row width is 1, header".
[0050] By sequentially extracting the data content and format attributes corresponding to each cell in the table to be converted, the data content and format attributes corresponding to each cell can be directly converted in form, thereby improving the efficiency of table conversion.
[0051] Step S20: According to a preset format conversion strategy, the data content and format attributes corresponding to each cell are converted to obtain target data corresponding to the table to be converted, wherein the target data includes a string array and a key-value pair array.
[0052] The preset format conversion strategy may include: converting the data content in the cell into a string format, converting the format attributes corresponding to the cell into a key-value pair format, wherein the parameter field and field value in the format attribute are represented in the key-value pair format.
[0053] Exemplarily, the target data includes multiple string arrays and multiple key-value pair arrays; wherein the data content in each row of cells is converted into a string and assigned to the corresponding string array, and the key-value pairs corresponding to the format attributes of each row of cells are converted and assigned to the corresponding key-value pair array. By distinguishing between string arrays and key-value pair arrays for cells in different rows, when rendering the target data to a web page, each string array corresponds to the data content in one row of cells in a web page table, and each key-value pair array is used to format the format of the corresponding row of cells. This can improve the efficiency of rendering the target data to the web page and avoid confusion between the data content and format attributes corresponding to each row of cells.
[0054] See also Figure 2 In some embodiments, before performing format conversion on the data content and format attributes corresponding to each cell according to a preset format conversion strategy, the following steps S201 and S202 may be specifically included.
[0055] Step S201: Determine whether there are merged cells in the table to be converted based on the format attributes corresponding to the cells.
[0056] Specifically, whether a cell is a merged cell can be determined based on the column width and row width parameters in the format properties.
[0057] For example, if the column width corresponding to cell A is 2 and the row width is 1, then cell A can be determined to be a merged cell with two columns. For example, if the column width corresponding to cell B is 2 and the row width is 2, then cell B can be determined to be a merged cell with two rows and two columns. For another example, if the column width corresponding to cell C is 1 and the row width is 1, then cell C can be determined to be a cell with a single row and single column.
[0058] Step S202: If there are merged cells, split the merged cells into cells in a single row and a single column, and obtain the data content and format attributes corresponding to each of the cells in the single row and a single column.
[0059] Specifically, the merged cell can be split into multiple cells of a single row and a single column based on a preset splitting strategy. The preset splitting strategy may include splitting the merged cell according to the principle of a single row and a single column.
[0060] For example, if cell A is a merged cell of two columns, cell A can be split into two sub-cells A1 and A2.
[0061] For example, if cell B is a merged cell of two rows and two columns, cell B can be split into four sub-cells: B1, B2, B3, and B4.
[0062] In some embodiments, matching the data content and format attributes corresponding to cells in each single row and column may include: obtaining the data content and format attributes corresponding to the merged cell, assigning the data content and format attributes corresponding to the merged cell to the first cell after the split; setting the data content corresponding to the remaining cells after the split to an empty value and setting the row width and column width in the format attributes to zero.
[0063] For example, if cell A is a merged cell of two columns, and the data content corresponding to cell A is "Test Header 1", and the format attribute is "column width is 2, row width is 1, header", and the split obtains two sub-cells A1 and A2, then sub-cell A1 is the first cell after the split. At this time, the data content and format attributes corresponding to cell A can be assigned to sub-cell A1, and the data content corresponding to sub-cell A1 is "Test Header 1", and the format attributes are "column width is 2, row width is 1, header". Sub-cell A2 is the remaining cell after the split, so the data content corresponding to sub-cell A2 can be set to an empty value, and the row width and column width in the format attributes corresponding to sub-cell A2 can be set to zero; the format attributes corresponding to sub-cell A2 are "column width is 0, row width is 0, header".
[0064] It should be noted that by retaining the header parameter in the format properties corresponding to the remaining cells after the split, it is used to indicate that the remaining cells are part of the merged cells before the split. Subsequently, it can be determined whether the remaining cells are header cells based on the header parameter in the format properties corresponding to the remaining cells.
[0065] For example, if cell B is a merged cell with two rows and two columns, and the data content corresponding to cell B is "Test Header 0", and the format attribute is "column width is 2, row width is 2, header", and the four sub-cells B1, B2, B3 and B4 are obtained by splitting, then sub-cell B1 is the first cell after the split. At this time, the data content and format attributes corresponding to cell B can be assigned to sub-cell B1, and the data content corresponding to sub-cell B1 is "Test Header 0", and the format attributes are "column width is 2, row width is 0, header". Sub-cells B2, B3 and B4 are the remaining cells after the split, so the data content corresponding to sub-cells B2, B3 and B4 can be set to null values, and the row width and column width in the format attributes corresponding to sub-cells B2, B3 and B4 can be set to zero; the format attributes corresponding to sub-cells B2, B3 and B4 are all "column width is 0, row width is 0, header".
[0066] It should be noted that the data content and format attributes corresponding to the original single-row and single-column cells that have not been split are retained accordingly.
[0067] For example, if cell C is a single-row, single-column cell, there is no need to split cell C; cell C retains its original data content and format attributes. For example, the data content corresponding to cell C is "Test Data 1" and the format attributes are "column width is 1, row width is 1."
[0068] Specifically, the merged cells are split into cells of a single row and a single column, and the data content and format attributes corresponding to the cells of each single row and a single column are matched to obtain the split table to be converted.
[0069] Table 2 is the table to be converted after splitting
[0070] Test header 0 Test header 1 Test header 2 Test header 3 Test header 4 Test header 5 Test header 6 Test header 7 Test header 8 Test data 0 Test data 1 Test Data 2 Test data 3 Test data 4 Test data 5 Test Data 6 Test data 7 Test data 8 Test data 9 Test data 10 Test data 11 Test data 12 Test data 13 Test data 14 Test data 15 Test data 16 Test data 17 Test data 18 Test data 19 Test data 20 Test data 21 Test data 22 Test data 23 Test data 24 Test data 25 Test data 26 Test data 27 Test data 28
[0071] By determining whether there are merged cells in the table to be converted based on the format attributes corresponding to the cells, the merged cells can be split into cells of a single row and a single column, thereby facilitating the formal conversion of the data content and format attributes corresponding to each cell.
[0072] See also Figure 2 , Figure 2 This is a schematic flow chart of converting the data content and format attributes corresponding to each cell according to a preset conversion strategy in step S20 to obtain target data corresponding to the table to be converted, which may specifically include the following steps S203 and S204.
[0073] Step S203 : Convert the data content corresponding to each row of cells into a string format in sequence to obtain a string array corresponding to each row of cells.
[0074] The string array includes the strings corresponding to the cells in each row.
[0075] Specifically, the data content corresponding to each row of cells is converted into a string format, and the strings obtained by converting each row of cells are assigned to the corresponding string array.
[0076] Illustratively, in the split table to be converted, the cells in the first row are as shown in Table 3.
[0077] Table 3 is the first row of cells
[0078] Test header 0 Test header 1 Test header 2 Test header 3
[0079] It should be noted that when converting the data content corresponding to a cell, if the data content is a null value, it is represented by an empty string.
[0080] For example, the data content corresponding to the cells in the first row is converted into a string format, and the strings obtained by converting the cells in the first row are assigned to the string array a. String data a: ["Test Header 0","","Test Header 1","","Test Header 2","","Test Header 3"].
[0081] For example, the data content corresponding to the cells in the second row is converted into a string format, and the converted strings are assigned to the string array b. String data b: ["","","Test Header 4","Test Header 5","Test Header 6","Test Header 7","Test Header 8"].
[0082] By converting the data content corresponding to each row of cells into a string format in turn, a string array corresponding to each row of cells can be obtained, thereby distinguishing the string arrays of cells in different rows.
[0083] Step S204: Based on the preset column attribute field, row attribute field, and header attribute field, the format attributes corresponding to the cells in each row are converted into key-value pairs in sequence to obtain a key-value pair array corresponding to the cells in each row.
[0084] The key-value pair array includes column attribute key-value pairs, row attribute key-value pairs, and / or header attribute key-value pairs corresponding to each row cell.
[0085] Exemplarily, the preset column attribute field is colspan, which is used to represent the column width parameter in the format attribute; the preset row attribute field is rowspan, which is used to represent the row width parameter in the format attribute; the preset header attribute fields include border and bold, which are used to represent the header parameters in the format attribute.
[0086] It should be noted that the header styles for table headers include bordered and bold. The header attribute field "border" indicates a bordered style, while the header attribute field "bold" indicates a bold style. For example, if a cell is a table header, the value corresponding to the header attribute field "border" and the value corresponding to the header attribute field "bold" for that cell are true, indicating that the cell is a table header cell.
[0087] For example, if the corresponding format attributes of a cell are: column width is 2, row width is 2, and table header; the corresponding format attributes of the cell are converted into key-value pairs, then the key-value pairs corresponding to the cell after conversion are: {"colspan":2,"rowspan":2,"bold":true,"border":true}.
[0088] Specifically, the format attributes corresponding to the cells in each row are converted into key-value pairs, and the key-value pairs obtained by converting the cells in each row are assigned to the corresponding key-value pair array.
[0089] For example, the format attributes corresponding to the cells in the first row of the table to be converted are converted into key-value pairs, and the key-value pairs obtained by converting the cells in the first row are assigned to the key-value pair array a. The key-value pair array a corresponding to the cells in the first row is as follows:
[0090] [{"colspan":2,"rowspan":2,"bold":true,"border":true},{"colspan":0,"rowspan":0,"bold":true,"border":true},{"colspan":2,"rowspan":1,"bold":true,"border":true},{"colspan":0,"rowspan":0," bold":true,"border":true},{"colspan":2,"rowspan":1,"bold":true,"border":true},{"colspan":0,"rowspan":0,"bold":true,"border":true},{"colspan":1,"rowspan":1,"bold":true,"border":true}].
[0091] For example, the format attributes corresponding to the cells in the third row of the table to be converted are converted into key-value pairs, and the key-value pairs obtained by converting the cells in the third row are assigned to the key-value pair array c. The key-value pair array c corresponding to the cells in the first row is obtained as follows:
[0092] [{"colspan":2,"rowspan":3},{"colspan":0,"rowspan":0},{"colspan":1,"rowspan":1},{"colspan":1, "rowspan":1},{"colspan":1,"rowspan":1},{"colspan":1,"rowspan":1},{"colspan":1,"rowspan":1}].
[0093] It should be noted that when a cell is not a header cell, it is not necessary to use the header attribute fields border and bold to represent the header attribute key-value pair of the cell.
[0094] Based on the preset column attribute fields, row attribute fields, and header attribute fields, the format attributes corresponding to each row of cells are converted into key-value pairs in turn. During the rendering process, each row of cells can be formatted according to the key-value pair array, which can make format conversion more convenient and improve conversion efficiency.
[0095] Step S30: Render the string array and key-value pair array in the target data into a web page to obtain a target web page table corresponding to the table to be converted.
[0096] It should be noted that rendering refers to the process of parsing various resources or data through the browser rendering engine to output visual images or web pages. The browser rendering engine includes modules such as HTML parser, CSS parser, layout, and JavaScript engine.
[0097] See also Figure 3 , Figure 3 This is a schematic flow chart of rendering the string array and key-value pair array in the target data into the web page in step S30 to obtain the target web page table corresponding to the table to be converted, specifically including the following steps S301 to S303.
[0098] Step S301: Obtain a webpage table template.
[0099] It should be noted that an HTML table consists of a table and one or more tr, th, or td attribute tags. The table attribute tag is used to define a table; the tr attribute tag is used to define a table row; the th attribute tag is used to define a table header; and the td attribute tag is used to define a table cell.
[0100] In the embodiment of the present application, the initial webpage table may include but is not limited to cell attribute tags, row attribute tags, and header attribute tags. Among them, the cell attribute tag can be represented by td; the row attribute tag can be represented by tr; and the header attribute tag can be represented by th.
[0101] The row attribute tag is used to generate the number of rows in the table, and the cell attribute tag is used to generate the cells corresponding to each row in the table. For example, if there are N row attribute tags, N rows will be generated; if there are M cell attribute tags, M cells will be generated in each row.
[0102] Step S302: Add the character string array in the target data to the webpage form template to obtain an initial webpage form.
[0103] In some embodiments, adding the string array in the target data to the web page table template to obtain an initial web page table may include: determining the number of row attribute labels in the web page table template according to the number of groups corresponding to the string array in the target data; determining the number of cell attribute labels corresponding to each row in the web page table template according to the number of strings in each string array; determining the number of rows corresponding to the web page table template and the number of cells corresponding to each row according to the number of row attribute labels and the number of cell attribute labels corresponding to each row; and filling the strings in each string array into the cells of each row corresponding to the web page table template in sequence to obtain the initial web page table.
[0104] It should be noted that since each string array is obtained by converting the data corresponding to each row of cells into string format, each row of cells corresponds to a group of string arrays. Therefore, the number of rows corresponding to the row attribute labels can be determined based on the number of groups corresponding to the string arrays. In addition, when converting the data corresponding to each row of cells into string format, the cells in each row are all single-row and single-column cells, so the number of strings in each string array is the same. Therefore, the number of cells in the cell attribute labels corresponding to each row can be determined based on the number of strings in each string array.
[0105] For example, if the number of groups corresponding to the string array is 7, then it can be determined that the number of row attribute labels corresponding to the array is 7.
[0106] For example, if the number of strings in the string array is 7, for example ["Test Header 0","","Test Header 1","","Test Header 2","","Test Header 3"], it can be determined that the cell attribute labels corresponding to each row are 7, that is, each row includes 7 cells.
[0107] For example, if the number of row attribute tags corresponding to each row is 7, and the number of cell attribute tags corresponding to each row is 7, then it can be determined that the number of rows corresponding to the webpage table template is 7, and the number of cells corresponding to each row is 7.
[0108] Specifically, the strings in each string array are sequentially filled into the corresponding cells of each row of the webpage table template to obtain an initial webpage table. For example, the obtained initial webpage table is shown in Table 4.
[0109] Table 4 is the initial web page table
[0110] Test header 0 Test header 1 Test header 2 Test header 3 Test header 4 Test header 5 Test header 6 Test header 7 Test header 8 Test data 0 Test data 1 Test Data 2 Test data 3 Test data 4 Test data 5 Test Data 6 Test data 7 Test data 8 Test data 9 Test data 10 Test data 11 Test data 12 Test data 13 Test data 14 Test data 15 Test data 16 Test data 17 Test data 18 Test data 19 Test data 20 Test data 21 Test data 22 Test data 23 Test data 24 Test data 25 Test data 26 Test data 27 Test data 28
[0111] Step S303: Format the cells in the initial webpage table according to the key-value pair array in the target data to obtain a target webpage table corresponding to the table to be converted, wherein the target webpage table is stored in the blockchain.
[0112] It should be noted that in the embodiment of the present application, formatting refers to merging cells in the initial webpage table and adding a header style. It is understandable that not all cells in the initial webpage table are merged and the header style is added, but rather the cells that need to be merged and the header style are determined based on the key-value pair array in the target data.
[0113] In some embodiments, formatting cells in the initial web page table according to the key-value pair array in the target data to obtain a target web page table corresponding to the table to be converted may include: determining the column attribute values and row attribute values corresponding to the cell attribute labels in the initial web page table according to the column attribute key-value pairs and row attribute key-value pairs in the key-value pair array; determining the cells in the initial web page table that carry header attribute labels according to the header attribute key-value pairs in the key-value pair array; adding a preset header style to the cells that carry header attribute labels, and merging each cell according to the column attribute value and row attribute value of the cell attribute label corresponding to each cell to obtain the target web page table corresponding to the table to be converted.
[0114] By using the column attribute key-value pairs and row attribute key values in the key-value pair array, and the header attribute key-value pairs in the key-value pair array, the column attribute value and row attribute value corresponding to each cell attribute label and the cell carrying the header attribute label can be determined more quickly and accurately.
[0115] For example, if the key-value pair array a is: [{"colspan":2,"rowspan":2,"bold":true,"border":true},{"colspan":0,"rowspan":0,"bold":true,"border":true},{"colspan":2,"rowspan":1,"bold":true,"border":true},{"colspan":0,"rowspan":0,"bold":true,"border":true},{"colspan":2,"rowspan":1,"bold":true,"border":true} an":1,"bold":true,"border":true},{"colspan":0,"rowspan":0,"bold":true,"border":true},{"colspan":1,"rowspan":1,"bold":true,"border":true}], since the key-value pair array a corresponds to the format attributes of the cells in the first row, the column attribute values and row attribute values of the cell attribute labels corresponding to the cells in the first row of the initial web page table are {(2,2),(0,0),(2,1),(0,0),(2,1),(0,0),(1,1)} respectively.
[0116] Exemplarily, cells in the initial webpage table that carry header attribute tags are determined based on the header attribute key-value pairs in the key-value pair array. For example, cells that contain the key-value pair "bold":true and the key-value pair "border":true are considered cells that carry header attribute tags; cells that do not contain the key-value pair "bold":true and the key-value pair "border":true are not considered cells that carry header attribute tags.
[0117] Specifically, a preset header style is added to the cell carrying the header attribute tag; illustratively, the cell carrying the header attribute tag is bordered and the border is thickened.
[0118] Specifically, each cell is merged based on the column attribute value and row attribute value of the cell attribute tag corresponding to each cell. For example, if the column attribute value and row attribute value of the cell attribute tag corresponding to a cell are (2,2), it means that the cell needs to be merged to form a cell with two rows and two columns. For example, the cell is merged with the cell corresponding to the next row and the cell corresponding to the next column to obtain a cell with two rows and two columns.
[0119] It should be noted that, when merging cells, the merging can be done from left to right; cells with column and row attribute values of the cell attribute labels being (0,0) will not be displayed.
[0120] Illustratively, the target webpage table corresponding to the table to be converted is shown in Table 5.
[0121] Table 5 is the target web page table
[0122]
[0123] It should be emphasized that in order to further ensure the privacy and security of the above-mentioned target web page form, the above-mentioned target web page form can also be stored in a node of a blockchain.
[0124] By adding the string array in the target data to the web table template and formatting the cells in the initial web table according to the key-value pair array in the target data, the target web table can be generated more conveniently, thereby improving the efficiency of table conversion.
[0125] It should be noted that, in the embodiment of the present application, after obtaining the target webpage table corresponding to the table to be converted, the webpage table in the webpage can also be edited.
[0126] See also Figure 4 , the table conversion method may further include step S40.
[0127] Step S40: If a selection operation of a webpage table in a webpage by a user is obtained, a webpage table to be edited is determined according to the selection operation, and the webpage table to be edited is edited according to the editing operation of the user on the webpage table to be edited.
[0128] For example, a page includes multiple web forms, and a user can select a web form to be edited on the page. Therefore, according to the user's selection operation, the web form selected by the user can be used as the web form to be edited.
[0129] The editing operation may include but is not limited to operations such as adding content to a cell, hiding a cell, and expanding a cell.
[0130] Specifically, cells include two types: input boxes and pop-up windows. The Span tag can be used to display input boxes, while the Input tag can be used to display pop-up windows. For example, clicking a cell displays an input box, while double-clicking a cell displays a pop-up window. It should be noted that the Span tag is used to define sections in a document, while the Input tag is used to define input controls.
[0131] In some implementations, if an editing operation of adding content to a cell in a table on a webpage to be edited is obtained, content is added to the cell in the table on the webpage to be edited according to the editing operation.
[0132] For example, when the user clicks on a cell, the cell can be switched to an input box; and the content entered by the user in the input box is displayed. For example, when the user clicks on the cell "test data 1", the cell "test data 1" is switched to an input box, such as Figure 5 As shown in the figure, users can perform editing operations in the input box.
[0133] In some implementations, if an editing operation of setting a hidden cell in a table of a webpage to be edited by a user is obtained, the hidden cell is hidden according to the editing operation.
[0134] For example, when the user double-clicks a cell, a pop-up window corresponding to the cell can be displayed; and the cell can be hidden according to the parameters set by the user in the pop-up window. When the user double-clicks the cell "Test Data 1", the pop-up window displayed is as follows Figure 6 As shown; cells can be hidden according to the number of hidden rows and hidden status set by the user in the pop-up window.
[0135] Specifically, the user sets the number of hidden rows to 2 in the pop-up window and selects the hidden state, which can be achieved through the following code: mergeRules:{{"2-2":{"rows":2,"hidden":true}}; indicating that the data in the second row and second column is the trigger point for folding, and the two rows below are folded, and the initial state is hidden.
[0136] For example, according to the editing operation of the hidden cells set by the user, the cells of the webpage table to be edited are hidden, and the webpage table to be edited after the cells are hidden is as follows: Figure 7 shown.
[0137] In other embodiments, if an editing operation of expanding a hidden cell in a table of a webpage to be edited is obtained, the hidden cell is expanded according to the editing operation.
[0138] For example, when the user needs to expand the hidden cells again, they can click the fold trigger point and set it in the pop-up window that appears. For example, the number of hidden rows set to 0 and the hidden state is not selected. This can be achieved through the following code: mergeRules:{{"2-2":{"rows":0,"hidden":false}}; indicates that the data in the second row and second column is the trigger point for expansion, and the two rows below are expanded, with the initial state being non-hidden.
[0139] By editing the webpage table to be edited according to the user's editing operations on the webpage table to be edited, application scenarios such as modifying the data content in the cell, hiding cells, and expanding hidden cells can be realized, making it more convenient for users to edit the webpage table.
[0140] The table conversion method provided by the above embodiment sequentially extracts the data content and format attributes corresponding to each cell in the table to be converted, and subsequently directly performs format conversion on the data content and format attributes corresponding to each cell, thereby improving the efficiency of table conversion; by judging whether there are merged cells in the table to be converted according to the format attributes corresponding to the cells, the merged cells can be split into cells of a single row and a single column, thereby facilitating the format conversion of the data content and format attributes corresponding to each cell; by sequentially converting the data content corresponding to the cells of each row into a string form, a string array corresponding to the cells of each row can be obtained, thereby realizing the distinction of string arrays for cells of different rows; by using the preset column attribute field and row attribute field The paragraph and header attribute fields convert the format attributes corresponding to each row of cells into key-value pairs in turn. During the rendering process, each row of cells can be formatted according to the key-value pair array, which can make format conversion more convenient; by adding the string array in the target data to the web table template, and formatting the cells in the initial web table according to the key-value pair array in the target data, the target web table can be generated more conveniently, which improves the efficiency of table conversion; by editing the web table to be edited according to the user's editing operations on the web table to be edited, application scenarios such as modifying the data content in the cell, hiding the cell, and expanding the hidden cell can be realized, making it more convenient for users to edit the web table.
[0141] See also Figure 8 , Figure 8 The embodiment of the present application further provides a schematic block diagram of a table conversion device 100, which is used to execute the aforementioned table conversion method. The table conversion device can be configured in a server or a terminal.
[0142] like Figure 8 As shown, the table conversion device 100 includes: a data acquisition module 101 , a form conversion module 102 , a data rendering module 103 and a table editing module 104 .
[0143] The data acquisition module 101 is used to acquire a table to be converted and extract the data content and format attributes corresponding to each cell in the table to be converted.
[0144] The form conversion module 102 is used to perform form conversion on the data content and format attributes corresponding to each cell according to a preset form conversion strategy to obtain target data corresponding to the table to be converted, wherein the target data includes a string array and a key-value pair array.
[0145] The data rendering module 103 is configured to render the string array and key-value pair array in the target data into a web page to obtain a target web page table corresponding to the table to be converted.
[0146] The table editing module 104 is configured to determine a table to be edited according to the selection operation if a user selects a table in a webpage, and edit the table according to the user's editing operation.
[0147] It should be noted that those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0148] The above-mentioned device can be realized in the form of a computer program. The computer program can be used in Figure 9 Runs on the computer device shown.
[0149] See also Figure 9 , Figure 9 This is a schematic block diagram of the structure of a computer device provided in an embodiment of the present application. The computer device may be a server or a terminal.
[0150] See also Figure 9 The computer device includes a processor and a memory connected via a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.
[0151] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
[0152] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any table conversion method.
[0153] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0154] In one embodiment, the processor is configured to execute a computer program stored in the memory to implement the following steps:
[0155] Obtain a table to be converted, and extract the data content and format attributes corresponding to each cell in the table to be converted; perform form conversion on the data content and format attributes corresponding to each cell according to a preset form conversion strategy to obtain target data corresponding to the table to be converted, wherein the target data includes a string array and a key-value pair array; render the string array and key-value pair array in the target data into a web page to obtain a target web page table corresponding to the table to be converted.
[0156] In one embodiment, before the processor performs format conversion on the data content and format attributes corresponding to each cell according to a preset format conversion strategy to obtain the target data corresponding to the table to be converted, the processor is further configured to implement:
[0157] According to the format attributes corresponding to the cells, determine whether the table to be converted has merged cells; if there are merged cells, split the merged cells into cells of a single row and a single column, and match the data content and format attributes corresponding to each of the cells of a single row and a single column.
[0158] In one embodiment, the format attributes include row width and column width; when matching the data content and format attributes corresponding to the cells of each single row and column, the processor is configured to implement:
[0159] The data content and format attributes corresponding to the merged cell are obtained, and the data content and format attributes corresponding to the merged cell are assigned to the first cell after the split; the data content corresponding to the remaining cells after the split is set to a null value and the row width and column width in the format attributes are set to zero.
[0160] In one embodiment, when the processor performs format conversion on the data content and format attributes corresponding to each cell according to a preset format conversion strategy to obtain target data corresponding to the table to be converted, it is configured to implement:
[0161] Convert the data content corresponding to each row of cells into a string form in turn to obtain a string array corresponding to each row of cells, wherein the string array includes the strings corresponding to each row of cells; based on the preset column attribute field, row attribute field and header attribute field, convert the format attributes corresponding to each row of cells into a key-value pair form in turn to obtain a key-value pair array corresponding to each row of cells, wherein the key-value pair array includes the column attribute key-value pairs, row attribute key-value pairs and / or header attribute key-value pairs corresponding to each row of cells.
[0162] In one embodiment, when rendering the string array and key-value pair array in the target data into a webpage to obtain the target webpage table corresponding to the table to be converted, the processor is configured to implement:
[0163] Obtain a webpage table template; add the string array in the target data to the webpage table template to obtain an initial webpage table; format cells in the initial webpage table according to the key-value pair array in the target data to obtain a target webpage table corresponding to the table to be converted, wherein the target webpage table is stored in the blockchain.
[0164] In one embodiment, the webpage table template includes a row attribute tag, a cell attribute tag, and a header attribute tag; when the processor adds the string array in the target data to the webpage table template to obtain the initial webpage table, it is used to implement:
[0165] According to the number of groups corresponding to the string array in the target data, the number of row attribute labels in the web page table template is determined; according to the number of strings in each string array, the number of cell attribute labels corresponding to each row in the web page table template is determined; according to the number of row attribute labels and the number of cell attribute labels corresponding to each row, the number of rows corresponding to the web page table template and the number of cells corresponding to each row are determined; the strings in each string array are sequentially filled into the cells of each row corresponding to the web page table template to obtain an initial web page table.
[0166] In one embodiment, when the processor formats the cells in the initial webpage table according to the key-value pair array in the target data to obtain the target webpage table corresponding to the table to be converted, the processor is configured to implement:
[0167] According to the column attribute key-value pairs and row attribute key-value pairs in the key-value pair array, the column attribute values and row attribute values of the cell attribute tags corresponding to each cell in the initial web page table are determined; according to the header attribute key-value pairs in the key-value pair array, the cells carrying the header attribute tags in the initial web page table are determined; a preset header style is added to the cells carrying the header attribute tags, and the cells are merged according to the column attribute values and row attribute values of the cell attribute tags corresponding to the cells to obtain the target web page table corresponding to the table to be converted.
[0168] In one embodiment, after rendering the string array and key-value pair array in the target data into a webpage to obtain a target webpage table corresponding to the table to be converted, the processor is further configured to implement:
[0169] If a selection operation of a webpage table in a webpage by a user is obtained, a webpage table to be edited is determined according to the selection operation, and the webpage table to be edited is edited according to the editing operation of the user on the webpage table to be edited.
[0170] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and the processor executes the program instructions to implement any table conversion method provided in the embodiment of the present application.
[0171] The computer-readable storage medium may be an internal storage unit of the computer device described in the aforementioned embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a SmartMedia Card (SMC), a Secure Digital Card (SD Card), a flash memory card, etc. equipped on the computer device.
[0172] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0173] The blockchain referred to in this application is a new application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity of this information (to prevent counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.
[0174] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present application, and such modifications or substitutions should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A table conversion method, characterized in that: include: Obtaining a table to be converted, and extracting data content and format attributes corresponding to each cell in the table to be converted; According to a preset form conversion strategy, the data content and format attributes corresponding to each of the cells are converted to obtain target data corresponding to the table to be converted, wherein the form conversion strategy includes converting the data content in each of the cells into a string form, and converting the format attributes corresponding to each of the cells into a key-value pair form, and the target data includes a string array and a key-value pair array, and the strings obtained by converting the data content in the cells of each row are assigned to the corresponding string array, and the key-value pairs obtained by converting the format attributes corresponding to the cells of each row are assigned to the corresponding key-value pair array; The string array and key-value pair array in the target data are rendered into a web page to obtain a target web page table corresponding to the table to be converted.
2. The table conversion method according to claim 1, wherein: Before converting the data content and format attributes corresponding to each cell according to a preset format conversion strategy to obtain target data corresponding to the table to be converted, the method further includes: Determining whether there are merged cells in the table to be converted based on the format attributes corresponding to the cells; If there are merged cells, the merged cells are split into cells in a single row and a single column, and the data content and format attributes corresponding to the cells in the single row and a single column are matched.
3. The table conversion method according to claim 2, characterized in that: The format attributes include row width and column width; the data content and format attributes corresponding to the cells of each single row and column are matched, including: Obtain the data content and format attributes corresponding to the merged cell, and assign the data content and format attributes corresponding to the merged cell to the first cell after splitting; Set the data content corresponding to the remaining cells after splitting to empty values and set the row width and column width in the format properties to zero.
4. The table conversion method according to claim 2, wherein: The method of converting the data content and format attributes corresponding to each cell according to a preset format conversion strategy to obtain target data corresponding to the table to be converted includes: Converting the data content corresponding to each row of cells into a string format in sequence to obtain a string array corresponding to each row of cells, wherein the string array includes the strings corresponding to each row of cells; Based on the preset column attribute fields, row attribute fields and header attribute fields, the format attributes corresponding to the cells in each row are converted into key-value pairs in turn to obtain a key-value pair array corresponding to the cells in each row, wherein the key-value pair array includes the column attribute key-value pairs, row attribute key-value pairs and / or header attribute key-value pairs corresponding to the cells in each row.
5. The table conversion method according to claim 1, wherein: The step of rendering the string array and key-value pair array in the target data into a web page to obtain a target web page table corresponding to the table to be converted includes: Get the web form template; Adding the string array in the target data to the webpage table template to obtain an initial webpage table; Formatting cells in the initial webpage table according to the key-value pair array in the target data to obtain a target webpage table corresponding to the table to be converted, wherein the target webpage table is stored in the blockchain.
6. The table conversion method according to claim 5, characterized in that: The webpage table template includes a row attribute tag, a cell attribute tag, and a header attribute tag; the string array in the target data is added to the webpage table template to obtain an initial webpage table, including: Determining the number of row attribute labels in the webpage table template according to the number of groups corresponding to the string array in the target data; Determining the number of cell attribute labels corresponding to each row in the webpage table template according to the number of character strings in each character string array; Determining the number of rows corresponding to the webpage table template and the number of cells corresponding to each row according to the number of row attribute tags and the number of cell attribute tags corresponding to each row; Filling the strings in each string array into the corresponding row cells of the webpage table template in sequence to obtain an initial webpage table; The step of formatting the cells in the initial webpage table according to the key-value pair array in the target data to obtain the target webpage table corresponding to the table to be converted includes: Determining the column attribute value and the row attribute value of the cell attribute tag corresponding to each cell in the initial webpage table according to the column attribute key-value pairs and the row attribute key-value pairs in the key-value pair array; Determining cells in the initial webpage table that carry header attribute tags based on the header attribute key-value pairs in the key-value pair array; A preset header style is added to the cells carrying the header attribute tags, and the cells are merged according to the column attribute values and row attribute values of the cell attribute tags corresponding to the cells to obtain the target webpage table corresponding to the table to be converted.
7. The table conversion method according to any one of claims 1 to 6, characterized in that: After rendering the string array and key-value pair array in the target data into a webpage to obtain a target webpage table corresponding to the table to be converted, the method further includes: If a selection operation of a webpage table in a webpage by a user is obtained, a webpage table to be edited is determined according to the selection operation, and the webpage table to be edited is edited according to the editing operation of the user on the webpage table to be edited.
8. A table conversion device, characterized in that: Used to execute the table conversion method according to any one of claims 1 to 7, the table conversion device comprises: A data acquisition module is used to acquire a table to be converted and extract the data content and format attributes corresponding to each cell in the table to be converted; a form conversion module, configured to perform form conversion on the data content and format attributes corresponding to each of the cells according to a preset form conversion strategy, to obtain target data corresponding to the table to be converted, wherein the target data includes a string array and a key-value pair array; The data rendering module is used to render the string array and key-value pair array in the target data into a web page to obtain a target web page table corresponding to the table to be converted.
9. A computer device, characterized in that: The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is configured to execute the computer program and implement the table conversion method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the table conversion method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Page complex table rendering method and system, terminal and medium
CN110096507A
Page style conversion method and device, terminal device and storage medium
CN110795099A
Data conversion method, computer program performing data conversion, and data conversion device
JP2007072833A