Page table exporting method and device
By creating table objects and generating table export files in target format, the problem of page table export dependence on front-end interaction in the existing technology is solved, and an efficient and dependency-free export process is realized, improving user experience.
Patent Information
- Application Number
- CN202411453210.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2025-02-07
AI Technical Summary
The existing page table export method relies on front-end interactions, increasing the front-end dependence on the back-end, resulting in increased labor and time costs, and is susceptible to network status, resulting in poor user experience.
By creating a table object corresponding to a page table, traversing the table structure, determining the properties of the table object according to the attribute description method of the target format, and generating a table export file with the target format based on these attributes.
It realizes page table export without relying on the backend, saving time in front-end interaction, improving export efficiency, and improving user experience when network status is poor.
Smart Images

Figure CN119397996A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular, to a page table exporting method, a page table exporting apparatus, a computing device, a computer-readable storage medium, and a computer program product. Background Art
[0002] In the relevant technical field, exporting page tables is a common demand. For example, for HTML tables, there is often a demand to export them as Excel tables, so that the exported tables can be edited, stored or used for other data analysis needs. At present, the mainstream page table export solution is: the front end transmits the table data to the back end, the back end generates a table in the desired format by parsing it, and returns the generated table to the front end, such as returning the download link of the generated table, so that the front end can download the exported table. However, this export method not only increases the front end's dependence on the back end, but also increases a lot of manpower and time costs. Moreover, this implementation method that relies on the interaction between the front and back ends is easily affected by the network status, and may lead to a poor user experience when the network status is not good. Summary of the invention
[0003] In view of this, the present disclosure provides a page table export method, a page table export apparatus, a computing device, a computer-readable storage medium, and a computer program product, which can alleviate, mitigate or even eliminate the above-mentioned problems.
[0004] According to one aspect of the present disclosure, a page table export method is provided, including: obtaining a table structure of a page table, wherein the page table includes at least one cell, and the at least one cell forms at least one row and at least one column; creating a table object corresponding to the page table; traversing the table structure, and determining table object properties of the table object according to a property description method supported by a target format, wherein the table object properties include at least one property related to a column, row or cell of the page table; and generating a table export file having a target format corresponding to the page table based on at least a portion of the table object properties of the table object.
[0005] In some embodiments, table object properties include at least one of column properties and row properties, and, wherein, traversing the table structure and determining the table object properties of the table object according to the property description method supported by the target format includes at least one of the following items: traversing the tags related to the columns in the table structure, reading the width of each column in at least one column, and determining the column properties based on the read width; traversing the tags related to the rows in the table structure, reading the height of each row in at least one row, and determining the row properties based on the read height.
[0006] In some embodiments, table object properties include merge properties, and, wherein, traversing the table structure and determining the table object properties of the table object according to the property description method supported by the target format includes: traversing the cells in the table structure, wherein, for a cell with a row merge property or a column merge property, based on the index data of the cell and the number of rows indicated by the row merge property of the cell or the number of columns indicated by the column merge property, determining the merge information corresponding to the cell, the merge information including one or more of the following items: a starting row index, an ending row index, a starting column index, and an ending column index; determining the merge property based on the merge information corresponding to at least one cell.
[0007] In some embodiments, table object properties include cell properties, and, wherein, traversing the table structure and determining the table object properties of the table object according to the property description method supported by the target format includes: traversing the cells in the table structure, for each cell, creating a cell object corresponding to the cell, and determining the cell object properties of the created cell object, the cell object properties including at least one of the following: cell value, cell format, cell data type, cell style, cell picture information; determining the cell properties based on the cell objects corresponding to each cell.
[0008] In some embodiments, determining the cell object properties of the created cell object includes: in response to the cell corresponding to the cell object having a custom cell value, determining the cell value of the cell object as the custom cell value; in response to the cell corresponding to the cell object not having a custom cell value, extracting the value in the cell as the cell value of the cell object.
[0009] In some embodiments, determining the cell object properties of the created cell object includes: in response to the cell corresponding to the cell object having a custom cell format, determining the cell format of the cell object as the custom cell format; in response to the cell corresponding to the cell object not having a custom cell format, determining the cell format of the cell object as the default cell format.
[0010] In some embodiments, determining the cell object properties of the created cell object includes: in response to the cell corresponding to the cell object having a custom cell data type, determining the cell data type of the cell object as the custom cell data type; in response to the cell corresponding to the cell object not having the custom cell data type, inferring the type of the cell value of the cell as the cell data type of the cell object.
[0011] In some embodiments, determining the cell object properties of the created cell object includes: obtaining the rendering style of the corresponding cell presented by the browser through an element style acquisition method supported by the browser, the rendering style including at least one of the following items: rendering font style, rendering alignment style, rendering border style; based on the acquired rendering style, determining the cell style of the cell object according to the mapping relationship between the element style supported by the browser and the element style of the target format.
[0012] In some embodiments, the rendering style includes a rendering font style, the cell style includes a font style, and, wherein, based on the acquired rendering style, according to a mapping relationship between an element style supported by the browser and an element style of a target format, determining that the cell style of a cell object includes at least one of the following items: determining a size attribute in the font style based on the font size in the rendering font style; determining a name attribute in the font style based on the font name in response to the font name in the rendering font style existing in a font name dictionary supported by the target format, otherwise, determining the name attribute in the font style as a default font name; performing format conversion on the font color in the rendering font style to obtain color data in a color format supported by the target format as a color attribute in the font style; determining bold, italic, underline or strikethrough attributes in the font style based on a preset mapping relationship based on style attributes in the rendering font style indicating font thickness, whether it is italic, whether it is underlined or whether it is struckthrough.
[0013] In some embodiments, the rendering style includes a rendering alignment style, the cell style includes an alignment style, and, based on the acquired rendering style, according to a mapping relationship between element styles supported by the browser and element styles of a target format, determining the cell style of a cell object includes: based on an attribute in the rendering alignment style indicating whether to automatically wrap, horizontally align, or vertically align, determining the automatic wrap, horizontal alignment, or vertical alignment attribute in the alignment style according to a preset mapping relationship.
[0014] In some embodiments, the rendering style includes a rendering border style, the cell style includes a border style, and, based on the acquired rendering style, according to a mapping relationship between an element style supported by the browser and an element style of a target format, determining that the cell style of the cell object includes at least one of the following items: performing format conversion on the border color in the rendering border style to obtain color data in a color format supported by the target format as a color attribute in the border style; and determining, based on an attribute indicating a border line style in the rendering border style and according to a preset mapping relationship, a line style attribute in the border style.
[0015] In some embodiments, determining the cell object properties of the created cell object includes: in response to the corresponding cell containing a tag related to the picture, obtaining picture data based on the tag; converting the picture data into picture encoding data supported by the target format; and determining the cell picture information of the cell object based at least on the picture encoding data.
[0016] In some embodiments, converting the image data into image coding data supported by the target format includes: in response to a tag indicating that the image data is in an expected format, directly converting the image data into image coding data supported by the target format, wherein the expected format is a format that can be directly converted into image coding data supported by the target format; in response to a tag indicating that the image data is not in an expected format, creating a picture object in the expected format, drawing the picture data in the picture object, and converting the drawn picture data into picture coding data supported by the target format.
[0017] In some embodiments, generating a table export file having a target format corresponding to a page table based on at least a portion of table object properties of the table object includes: creating a target table object based on the target format; mapping at least a portion of the table object properties of the table object to target object properties of the target table object; and generating a table export based on the target object properties of the target table object.
[0018] In some embodiments, generating a table export file having a target format corresponding to a page table based on at least a portion of table object properties of the table object includes: obtaining a user configuration, the user configuration indicating whether to export or not to export at least a portion of the table object properties of the table object; and generating a table export file having a target format corresponding to the page table based on at least a portion of the table object properties of the table object according to the user configuration.
[0019] In some embodiments, the method further includes: in response to the absence of a label related to the row in the table structure, stopping exporting the page table and reporting an error.
[0020] According to another aspect of the present disclosure, a page table export device is provided, including: an acquisition module, configured to: acquire a table structure of a page table, wherein the page table includes at least one cell, and the at least one cell forms at least one row and at least one column; a creation module, configured to: create a table object corresponding to the page table; a determination module, configured to: traverse the table structure, and determine the table object properties of the table object according to the property description method supported by the target format, wherein the table object properties include at least one property related to the column, row or cell of the page table; a generation module, configured to: generate a table export file with a target format corresponding to the page table based on at least a part of the table object properties of the table object.
[0021] According to another aspect of the present disclosure, a computing device is provided, comprising: a memory configured to store computer-executable instructions; and a processor configured to execute the method described in any one of the embodiments of the foregoing aspects when the computer-executable instructions are executed by the processor.
[0022] According to another aspect of the present disclosure, a computer-readable storage medium is provided, which stores computer-executable instructions. When the computer-executable instructions are executed, the method described in any one of the embodiments in the aforementioned aspects is executed.
[0023] According to another aspect of the present disclosure, a computer program product is provided, comprising computer executable instructions, which implement the steps of the method described in any one of the embodiments in the foregoing aspects when executed by a processor.
[0024] Through the page table export method provided by the present disclosure, a table object corresponding to the page table to be exported can be created, the table structure of the page table can be traversed, the table object properties of the table object can be determined according to the property description method supported by the target format to be exported, and a table export file can be generated based on at least a part of the determined table object properties. Thus, the page table can be exported without relying on the back-end operation, which helps to save the time of front-end and back-end interaction, improve the export efficiency of the page table, and help improve the user experience when the network status is not good.
[0025] These and other aspects of the disclosure will be apparent from and elucidated with reference to the embodiments described hereinafter. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Further details, features and advantages of the present disclosure are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which:
[0027] Figure 1 An example flow chart of a page table export method according to some embodiments of the present disclosure is schematically shown;
[0028] Figure 2 Schematically illustrates an example of a page table according to some embodiments of the present disclosure;
[0029] Figure 3 An example flow chart of a table determination process according to some embodiments of the present disclosure is schematically shown;
[0030] Figure 4 Schematically illustrates an example flow chart of a cell value determination process according to some embodiments of the present disclosure;
[0031] Figure 5An example flowchart of a cell format determination process according to some embodiments of the present disclosure is schematically shown;
[0032] Figure 6 Schematically illustrates an example flow chart of a cell data type determination process according to some embodiments of the present disclosure;
[0033] Figure 7 An example flow chart schematically illustrates a process for determining cell picture information according to some embodiments of the present disclosure;
[0034] Figure 8 Schematically shows an example block diagram of a page table exporting device according to some embodiments of the present disclosure;
[0035] Fig. 9 An example block diagram of a computing device according to some embodiments of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0036] In the present disclosure, a page table can be understood as a table presented by a web page. Optionally, a user can use various browsers to view such a page table. Exemplarily, the page table can be an HTML table, that is, a table described by HTML (Hypertext Markup Language), or, in some application scenarios, the page table can also be other types of tables described in other languages.
[0037] Taking HTML tables as an example, as mentioned above, there is often a need to export them to Excel tables for analysis, editing and storage. However, conventional table export solutions based on front-end and back-end interaction will bring many problems. In the relevant technology, there are also some HTML table export solutions based on js-xlsx library, xlsx-style library, exceljs library, etc. However, these solutions often lose some table information such as font style, border style, picture data, etc., or the operation is relatively complicated, and different export programs need to be written for different tables.
[0038] Based on the above considerations, the present disclosure proposes a new page table export solution, which can not only realize the export of page tables without relying on the backend, but also relatively completely retain various attribute information of the page table, and can accurately export most page tables to table files in the target format in a relatively simple and efficient manner. The proposed page table export solution will be described in detail below with reference to the accompanying drawings.
[0039] Figure 1 An example flow chart of a page table exporting method 100 according to some embodiments of the present disclosure is schematically shown.
[0040] In step 110, the table structure of the page table can be obtained, wherein the page table can include at least one cell, and the at least one cell can form at least one row and at least one column. In some embodiments, the table structure of the page table to be exported can be obtained based on the identifier of the page table to be exported, such as a table ID, a table name, or other forms of identifiers. Exemplarily, the export of the page table can be initiated by calling method 100, wherein when calling method 100, the identifier of the page table to be exported can be provided. Further exemplarily, when the user initiates a page table export operation, for example, when the user selects a table on the page and selects to perform a page table export operation through a menu option or other means, the front end can respond to the operation, obtain the table identifier of the table, and call method 100 based on the obtained table identifier to export the table. The table structure of the page table can be understood as data used to describe or characterize the structure of the page table, such as a page table layout structure, a hierarchical structure, etc., which may include, for example, data related to the position of cells, the relationship between cells, the row and column positions of cells, etc. And, the table structure may also include cell data and attribute data of the page table, such as attribute data related to the format, style, etc. of rows, columns, cells, or data therein. Optionally, the DOM (Document Object Model) structure of the page table or a table structure described in other ways may be obtained. In the example of using DOM, the structure of the page table may be described by a DOM tree structure, and the DOM structure of the page table may be obtained by related instructions based on the identifier of the page table. The acquisition of the above DOM structure or other types of table structures may be performed according to methods known in the art, and will not be described in detail here.
[0041] For ease of understanding, here is an example of a page table code:
[0042]
[0043]
[0044]
[0045]
[0046]
[0047]
[0048]
[0049]
[0050]
[0051]
[0052]
[0053]
[0054]
[0055]
[0056]
[0057]
[0058]
[0059]
[0060]
[0061]
[0062]
[0063]
[0066]
[0067]
[0068]
[0071]
[0072] <table id=‘table-id’> <col style=‘width:100px’> <col style=‘width:120px’> <col style=‘width:150px’> <col style=‘width:80px’> <td data-z=‘0.00%’rowspan=‘2’>6.86 <td data-t=‘s’>980876.876 <td data-v=‘999’>980876.876 980876.876 2024 / 3 / 25 <td style=’border-top:1px solid#ddd;font-size:14px;font-weight:700;color:#678;text-align:center;vertical-align:middle;text-decoration:underline;font-style:italic’>980876.876 TRUE <td colspan=‘4’>
[0064] <canvas>
[0065] < / canvas> <td colspan=‘4’>
[0069] <img src=‘. image.png’>
[0070]
[0073] Among them, the page table consists of Figure 2 Figure 2
[0074]
[0075]
[0076] Figure 3
[0081]
[0082]
[0083]
[0084]
[0085]
[0086]
[0087]
[0088]
[0089] The page table can contain and Two sub-elements, Tags include Sub-elements can be used to define the width or other properties of each column of the table. Tags can be used to define a row in a table. Tags include Tags can be used to define a cell. For example, there are four Tag, which means that it includes four rows. Schematically, the page table defined by the above code can be as shown. It should be understood that the above code and the page table shown are only exemplary, and the technical solution provided by the present disclosure can also be applied to other forms of page tables. In some embodiments, multiple page tables can also be exported synchronously according to user instructions. At this time, the identifiers of two or more page tables can be obtained according to the user's page table export operation or related instructions, and the table structure of the corresponding two or more page tables can be obtained. Subsequently, for each page table, it can be parsed and exported according to the various embodiments described below. Exemplarily, the two or more page tables can be exported to the same table export file, wherein each page table can correspond to a page in the table export file, such as a sheet page in an Excel file. In step 120, a table object corresponding to the page table can be created. Exemplarily, the created table object can have a specified preset data structure so as to store various data related to the page table in an orderly manner according to the desired method. For example, the table object can have a table object attribute for storing attributes related to rows, columns or cells of the page table. Further exemplarily, in order to store various types of attribute data in an orderly manner and facilitate the export of tables in the target format, a table object sheet corresponding to the page table can be defined, and the object can have one or more table object attributes such as column attributes "!cols", row attributes "!rows", merge attributes "!merges" and cell attributes "!data", wherein "!cols", "!rows", "!merges" and "!data" can be used to store column information, row information, merged cell information and information of each cell, respectively. Optionally, other forms of table objects and table object attributes can also be defined according to specific application requirements. In step 130, the table structure can be traversed, and the table object attributes of the table object can be determined according to the attribute description method supported by the target format, wherein the table object attributes can include at least one attribute related to the column, row or cell of the page table. Exemplarily, the column, row or cell structure can be traversed in the table structure to obtain the attributes related to the column, row or cell of the page table, and the obtained attributes can be stored in the corresponding table object attributes in the attribute description method supported by the target format. Table object attributes may include the above-mentioned "!cols", "!rows", "!merges", "!data" and other attributes. Taking the page table code provided above as an example, you can traverse Each sub-tag in the tag To obtain the properties related to the columns of the page table, you can traverse Tag to get the attributes related to the row of the page table, and you can traverse each Each sub-tag in the tag To get the properties related to the cells of the page table.
[0077] In some embodiments, after determining the table object properties of the table object, the table object can be stored in a pre-created array, or can be stored in other ways. Exemplarily, in the case of synchronously exporting multiple page tables based on user instructions, after traversing the table structures of all page tables, the table objects corresponding to each page table can be stored in the empty array.
[0078] In step 140, a table export file in a target format corresponding to the page table may be generated based on at least a portion of the table object attributes of the table object. Alternatively, the table object may be written into a table in the target format with the aid of an existing library for reading and writing tables in the target format, and a corresponding table export file may be obtained. Alternatively, a table export file in a target format may be obtained based on the table object using a self-designed library or table writing method.
[0079] Through method 100, a pure front-end solution for exporting page tables is provided, which helps to reduce the complexity of exporting page tables (such as HTML tables, etc.) into table files of target formats (such as Excel files, etc.), eliminates the dependence of the front-end on the back-end during the export process, and avoids the impact of network fluctuations on the export process. In addition, through method 100, page table parsing and conversion operations can be automatically and completely implemented, so that front-end developers can directly call this method to implement related functions, thereby helping to reduce their workload and further helping to improve development efficiency.
[0080] In some embodiments, in order to avoid processing errors and waste of processing resources, the method 100 may further include a step of determining whether the page table to be exported is a table. For example, the method 100 may include: in response to the absence of a label related to a row in the table structure, stopping the page table export and reporting an error. Taking the page table code shown above as an example, in its table structure, if there is no label related to a row, tag, it can be determined that the page table to be exported does not actually have a table structure, for example, the identifier provided when calling method 100 is not the identifier of the page table, but the identifier of other types of objects or an invalid or erroneous identifier. This step can be performed after the aforementioned step 110 and before step 120 or 130. Exemplarily, as shown, after obtaining the table structure, for example, after executing step 110, step 310 can be executed to determine whether there are row-related tags in the table structure. If so, step 320 can be executed to traverse and parse the table structure to determine the table object properties, such as determining the table object properties through steps 120 or 130 described in the previous embodiments; if not, step 330 can be executed to throw an error and terminate execution. In some embodiments, it can be allowed to select whether to export at least part of the table object properties of the table object by providing user configuration, thereby increasing the flexibility of table export. Specifically, the aforementioned step 140 may include: obtaining a user configuration, which may indicate whether to export or not export at least a portion of the table object properties of the table object; generating a table export file having a target format corresponding to the page table based on at least a portion of the table object properties according to the user configuration. Exemplarily, when calling method 100 to export a page table, a user configuration may be provided at the same time, which may specify which properties need to be exported or which properties do not need to be exported, such as controlling whether the column width in the column properties, the row height in the row properties, and various formats or style properties in the cell object properties (such as font style, alignment style, border style, etc., cell styles, cell format, cell picture information, etc.) mentioned in the following embodiments need to be exported. If the above user configuration does not exist, the default configuration may be used. Under the default configuration, all table object properties will be completely exported. In some embodiments, in order to more conveniently realize the generation and acquisition of the table export file, the aforementioned step 140 may further include: creating a target table object based on the target format; mapping at least a portion of the table object properties of the table object to the target object properties of the target table object; generating a table export file based on the target object properties of the target table object. Exemplarily, a target table object can be created based on a library that supports table writing in a target format, and the table object attributes of the previously obtained table object or at least part of the table object attributes are mapped one by one to the target object attributes of the target table object. Subsequently, the target table object after the attribute mapping is completed can be further processed by the method provided by the above library to obtain a table export file. Furthermore, the table export file can be downloaded or otherwise obtained by various known methods or self-designed methods.Exemplarily, in the case of synchronously exporting multiple page tables based on user instructions, a target table object corresponding to the table object of each page table can be created, and the table object attributes of each table object can be mapped or partially mapped to the target object attributes of the corresponding target table object. Subsequently, each target table object can be exported to the same table export file, wherein different target table objects can correspond to different pages in the exported table. Exemplarily, when mapping at least a part of the table object attributes of the table object to the target object attributes of the target table object, the user configuration mentioned in the above embodiment can be considered. In the case of user configuration, the table object attributes that need to be mapped and exported can be determined according to the user configuration; in the case of no user configuration, all table object attributes can be mapped and exported by default. The table object attributes that do not need to be mapped can be ignored, and the target object attributes in the corresponding target table object can, for example, take the default settings. Continuing to take the export of HTML table to Excel table as an example, the table export file can be obtained based on the table object based on the ExcelJS library. The ExcelJS library is a relatively complete, relatively reasonably designed and relatively good performance library for Excel reading and writing. Alternatively, according to specific application requirements, other libraries for Excel reading and writing can also be used, or functional algorithms can be written by themselves to achieve the writing of Excel tables. Taking the ExcelJS library as an example, a workbook object can be created, and for table objects, such as the sheet object mentioned above, a corresponding worksheet object can be created using the method of the workbook object. Exemplarily, in the case of storing one or more sheet objects through an array, the array can be traversed, and a corresponding worksheet object can be created for each sheet object. Subsequently, for each sheet object, at least some of its! cols,! rows,! merges,! data attributes can be mapped one by one with the attributes of the worksheet object to determine the attributes of the corresponding worksheet object, such as the Cells attribute for cells in the table, the Rows attribute for rows in the table, and the Columns attribute for columns in the table and its sub-attributes. In addition, the name of each table page can also be set, for example, by setting the Name attribute of the worksheet object, such as setting it to the identifier of the corresponding page table or other custom or automatically generated names. Then, the worksheet object can be converted to an arrayBuffer object through the writeBuffer method of workbook. Finally, the arrayBuffer object can be converted to a Blob object through the saveAs method of file-saver, and the file name and file type can be set, and finally the file can be downloaded to the default download address of the browser or the specified address.File-saver is a widely used file download library, which is very suitable for file generation and downloading on the client side. Alternatively, according to specific application requirements, file downloading can also be achieved by other methods. Below, the content and determination method of the table object attributes mentioned in step 130 will be introduced in more detail. Exemplarily, the table object attributes may include column attributes, such as the "!cols" attribute mentioned in the previous embodiment, and step 130 may include: traversing the column-related labels in the table structure, reading the width of each column in at least one column, and determining the column attributes based on the read width. Taking the page table corresponding to the page table code example provided in the previous text as an example, its table structure can be traversed. Tags, get subtags And read the width of each column defined therein, and store it in the "!cols" attribute of the table object sheet. Exemplarily, the table object attributes may include row attributes, such as the "!rows" attribute mentioned in the above embodiment, and step 130 may include: traversing the row-related tags in the table structure, reading the height of each row in at least one row, and determining the row attributes based on the read height. Taking the page table corresponding to the page table code example provided above as an example, the table structure can be traversed. Tag, get the row attribute, read the data related to the row height such as clientHeight in the row attribute, and store it in the "!rows" attribute of the table object sheet as the row height. Exemplarily, the table object attribute may include merge attributes, such as the "!merges" attribute mentioned in the previous embodiment, and step 130 may include: traversing the cells in the table structure, wherein, for cells with row merge attributes or column merge attributes, based on the index data of the cell and the number of rows indicated by the row merge attribute of the cell or the number of columns indicated by the column merge attribute, determine the merge information corresponding to the cell, and the merge information may include one or more of the following items: starting row index, ending row index, starting column index, and ending column index; based on the merge information corresponding to at least one cell, determine the merge attribute. For example, when traversing to a cell, if there is a row merge attribute or a column merge attribute, one or more of the following steps can be performed: determine the starting row index based on the row index of the cell, determine the ending row index based on the sum of the row index of the cell and the number of rows indicated by the row merge attribute, determine the starting column index based on the column index of the cell, and determine the ending column index based on the sum of the column index of the cell and the number of columns indicated by the column merge attribute. Taking the page table corresponding to the page table code example provided above as an example, you can traverse the table structure in Tags, and iterate through each Under the label Tags are used to traverse each cell. During the traversal process, when a cell has colspan or rowspan attributes, its colspan or rowspan attributes can be extracted, and based on the cell index and colspan or rowspan attributes, the merge information of the cell can be obtained and stored in the "!merges" attribute of the sheet object.
[0090] Exemplarily, the table object attributes may include cell attributes, such as the "!data" attribute mentioned in the above embodiment, and step 130 may include: traversing the cells in the table structure, creating a cell object corresponding to the cell for each cell, and determining the cell object attributes of the created cell object, the cell object attributes may include at least one of the following items: cell value, cell format, cell data type, cell style, cell picture information; based on the cell objects corresponding to each cell, determining the cell attributes. The cell value, cell format, cell data type, cell style, and cell picture information can be used to store the cell value, format data, data type, style data, and picture information contained therein, respectively. Exemplarily, for each cell, the cell may be parsed, such as reading relevant values, formats, or style data based on the table structure, or obtaining the rendering style through a style acquisition method provided by a page browser, etc., to obtain the attribute data corresponding to one or more of the above cell object attributes of the cell. Subsequently, the attribute data obtained by parsing may be mapped to the attribute value under the target format according to the attribute description method supported by the target format, and stored in the corresponding cell object attribute. Exemplarily, after the traversal is completed, the cell object properties of all cells can be stored in the cell properties of the table object properties. For example, the cell index coordinates can be used as the key and the corresponding cell object properties can be used as the value to store the cell properties of the table object properties. In this way, the attribute data of each cell in the page table can be accurately and completely obtained. Optionally, in addition to the cell object properties listed above, other cell object properties can also be designed according to specific application requirements.
[0091] Still taking the page table corresponding to the page table code example provided in the previous article as an example, you can traverse its table structure Tags, and iterate through each Under the label Tag, thereby traversing each cell. During the traversal process, for each cell traversed to, a cell object can be defined, and the object can have five attributes of "v", "z", "t", "s" and "chart", which represent cell value, cell format, cell data type, cell style and cell picture information respectively. Exemplarily, "v", "z", "t" can be string types, "s" and "chart" can be object types, wherein the "s" object can have one or more attributes related to cell style, and the "chart" object can have one or more attributes related to cell pictures. For each cell, the above attributes can be obtained by parsing the cell, and the attribute description method supported by the target format (such as Excel table) is used to describe these attributes, and the corresponding object attributes are stored. After traversing and parsing all cells, the coordinates of the cell can be used as the key and the cell object as the value, and stored in the sheet object! data attribute.
[0092] In some embodiments, when parsing each cell, the Figure 4 The example flowchart shown is used to determine the cell value in the cell object property of the corresponding cell object. In step 410, it can be determined whether the cell has a custom cell value. In step 420, in response to the cell corresponding to the cell object having a custom cell value, the custom cell value can be obtained to determine the cell value of the cell object as the custom cell value. For example, the custom cell value can be directly assigned to the v property of the aforementioned cell object. In step 430, in response to the cell corresponding to the cell object not having a custom cell value, the value in the cell can be extracted as the cell value of the cell object. Taking an HTML table as an example, the innerHTML property of the cell can be read to obtain a string, which includes characters describing the label, value, etc. related to the cell. Then, the text in the label and sub-label can be extracted using a regular expression as the cell value of the cell object, such as assigned to the v property of the aforementioned cell object. The custom cell value can be defined by the designer of the page table, which can be used to specify the exported cell value of the cell when exporting the page table. Take the page table code provided in the previous example as an example, where data-v is a custom cell value. In the page table presented by the browser, the custom cell value will not be presented. For example, see Figure 2 The cell value of the cell in the first row and third column of the page table shown is "980876.876", instead of "999" specified by data-v in the sample code. In the corresponding exported table, this position will be presented as "999" instead of "980876.876". The above data-v is only exemplary, and custom cell values can also be set in other ways. Through this custom cell value, users can control the cell values they want to export, thereby improving the flexibility of table export.
[0093] In some embodiments, when parsing each cell, the Figure 5 The example flowchart shown is used to determine the cell format in the cell object attribute of the corresponding cell object. In step 510, it can be determined whether the cell has a custom cell format. In step 520, in response to the cell corresponding to the cell object having a custom cell format, the cell format of the cell object can be determined to be the custom cell format. For example, the custom cell format can be directly assigned to the z attribute of the aforementioned cell object. In step 530, in response to the cell corresponding to the cell object not having a custom cell format, the cell format of the cell object can be determined to be the default cell format. Optionally, the default cell format can be empty, that is, equivalent to skipping the step of determining the cell format, or other formats can be used as the default cell format according to specific application requirements. Similar to custom cell values, custom cell formats can also be defined by the designer of the page table, which can be used to specify the exported cell format of the cell when exporting the page table. Taking the page table code provided in the previous example as an example, data-z is a custom cell format, and the custom cell format will not be presented in the page table presented by the browser. For example, see Figure 2 The cell in the first row and first column of the page table shown (actually a merged cell, merging the cells in the first row and first column and the first row and second column) is in a normal numeric format, rather than the "0.00%" (data presented in percentage format) specified by data-z in the sample code. In the corresponding exported table, the data in this cell will be presented in percentage format. The above data-v is only exemplary, and custom cell formats can also be set in other ways. This custom cell format allows users to control the desired exported cell format, thereby improving the flexibility of table export.
[0094] In some embodiments, when parsing each cell, the cell data type in the cell object property of the cell object, such as the t property of the aforementioned cell object, can be determined by the following steps: In response to the cell corresponding to the cell object having a custom cell data type, the cell data type of the cell object can be determined as the custom cell data type; In response to the cell corresponding to the cell object not having a custom cell data type, the type of the cell value of the cell can be inferred as the cell data type of the cell object. Exemplarily, when inferring the type of the cell value of a cell, it can be inferred in turn whether the cell value belongs to one or more data types. If it is inferred that it belongs to a data type among the one or more data types, the inferred data type can be determined as the cell data type of the cell object; if it is inferred that it does not belong to any of the one or more data types, this can be regarded as an inference failure or an inability to infer the type of the cell value, and the cell data type of the cell object can be determined as a default data type. Similar to custom cell values or custom cell formats, custom cell data types can also be defined by the designer of the page table, which can be used to specify the exported cell data type of the cell when exporting the page table. Take the page table code provided in the previous example as an example, where data-t is a custom cell data type. In the page table presented by the browser, the custom cell data type will not be used. For example, see Figure 2 The data type of the cell in the first row and second column of the page table shown can be a number, rather than the "s" (character type) specified by data-z in the example code, and in the corresponding export table, the data in the cell will be presented as a string. The above data-t is only exemplary, and the custom cell data type can also be set in other ways. Through this custom cell data type, users can control the type of cell data they want to export, thereby improving the flexibility of table export. Exemplarily, the type of cell value can be inferred based on the cell value, such as the v attribute of the aforementioned cell object, to determine the cell data type of the corresponding cell object, such as the t attribute of the aforementioned cell object.
[0095] For example, it can be based on Figure 6 The example flowchart shown in FIG. 6 is used to determine the cell data type in the cell object property of the cell object. In step 601, it can be determined whether the cell has a custom cell data type. If it does, in step 602, the custom cell data type can be obtained as the cell data type of the cell object, such as the t attribute assigned to the aforementioned cell object. If it does not exist, the type of the cell value can be gradually inferred based on the cell value, and the cell data type of the cell object can be determined based on the inferred type. For example, in step 603, it can be determined whether the cell value is empty. If so, in step 604, the cell data type can be determined as "z" (empty); if not, it can proceed to step 605 to determine whether the cell value is "TRUE" or "FALSE". If so, in step 606, the cell data type can be determined as "b" (logical or Boolean); if not, it can proceed to step 607 to determine whether the cell value is a number. If so, in step 608, the cell data type can be determined as "n" (numeric); if not, it can proceed to step 609 to determine whether the cell value is a date. If so, then in step 610, the cell data type may be determined as "d" (date type); if not, then the process may proceed to step 611 to determine the cell data type as the default data type "s" (character type).
[0096] In some embodiments, when parsing each cell, the cell style in the cell object property of the cell object, such as the s property of the aforementioned cell object, can be determined by the following steps: obtaining the rendering style of the corresponding cell presented by the browser through the element style acquisition method supported by the browser, and the rendering style may include at least one of the following items: rendering font style, rendering alignment style, and rendering border style; based on the acquired rendering style, according to the mapping relationship between the element style supported by the browser and the element style of the target format, the cell style of the cell object is determined. Exemplarily, the s property of the aforementioned cell object can be an object type, and has properties related to the cell style, such as font style "font", alignment style "alignment", and border style "border", which can be obtained by mapping the acquired rendering font style, rendering alignment style, rendering border style, etc., wherein the mapped style description method can be a description method supported by the target format. For each cell, the style of the cell finally rendered on the page can be obtained through methods such as the getComputdStyle method or other element style acquisition methods widely supported by browsers. Therefore, on the one hand, you do not need to consider the style priority issues caused by different style setting methods such as class name selectors, ID selectors, tag selectors, inline styles, etc., which reduces the complexity of determining these style attributes. On the other hand, it also helps to ensure the consistency between the cell style in the exported table and the style presented on the page. Therefore, this helps to achieve better table export effects more simply and efficiently.
[0097] Exemplarily, for the font style attribute ("font") in the cell style, it can be determined based on the obtained cell's rendered font style. For example, the font style attribute can further include attributes such as size, name, color, bold, italic, underline, and strikethrough, which can respectively correspond to the cell's font size, font name, font color, thickness, whether italic, whether there is an underline, whether there is a strikethrough, and other rendering font styles obtained by parsing. Further exemplarily, after obtaining the font size (font-size), it can be directly stored in the size attribute. After obtaining the font name, the font name dictionary pre-established by referring to the font name list supported by the target format can be used to determine whether the obtained font name exists in the font name dictionary. If it exists, the corresponding value is stored in the name attribute. If it does not exist, the default font name is stored, such as "SimSun" (Songti) or other fonts. Exemplarily, the font name obtained by the getComputdStyle method can be a table such as font-family including multiple font names arranged in order of priority. At this time, it can be determined in turn whether each font name exists in the above font name dictionary. If a font name exists in the above font name dictionary, it is stored in the name attribute and the determination is stopped; if all font names do not exist in the above font name dictionary, the default font is stored in the name attribute. After obtaining the font color, the font color can be converted to a color format supported by the target format and then stored in the color attribute. Taking the export of HTML tables to Excel tables as an example, the color value obtained by the getComputedStyle method is generally in RGBA or RGB format, which needs to be converted to HEX before being stored in the color attribute. In addition, for styles such as thickness, italics, underline, and strikethrough, the obtained style can be mapped to the corresponding style attribute in the target format based on a pre-established mapping relationship. Taking the export of HTML tables to Excel tables as an example, the mapping of the above attributes can be achieved according to the mapping relationship described below. For bolding, the following mapping relationship table can be used:
[0098] Font-weight in HTML font.bold in Excel 400-600 false 700 true
[0099] For italics, the following mapping table can be used:
[0100] Font-style in HTML font.italic in Excel italic true oblique true etc false
[0101] To determine whether there is an underline, you can use the following mapping table:
[0102]
[0103] To determine whether there is a strikethrough, you can use the following mapping table:
[0104]
[0105] In addition, optionally, according to specific application requirements, other font style attributes may also be parsed and obtained.
[0106] Exemplarily, for the alignment style attribute ("alignment") in the cell style, it can be determined based on the obtained rendering alignment style of the cell. For example, the alignment style attribute can further include attributes such as automatic line break "wrapText", horizontal alignment "horizontal", and vertical alignment "vertical", which can respectively correspond to the rendering alignment styles such as whether to automatically wrap, horizontal alignment, and vertical alignment of the cell obtained by parsing. The obtained rendering alignment style can be mapped to the corresponding style attribute in the target format based on a pre-established mapping relationship. Taking the export of an HTML table to an Excel table as an example, the mapping of the above attributes can be implemented according to the mapping relationship described below. For whether to automatically wrap, the following mapping relationship table can be used:
[0107]
[0108] For horizontal alignment, the following mapping table can be used:
[0109]
[0110] For vertical alignment, the following mapping table can be used:
[0111]
[0112] In addition, optionally, according to specific application requirements, other alignment style attributes may also be parsed and obtained.
[0113] Exemplarily, for the border style attribute ("border") in the cell style, it can be determined based on the rendered border style of the obtained cell. For example, the border style attribute can specify whether the cell border is displayed and specify its color, style (such as solid line, dashed line and other line styles), etc. Generally speaking, a cell can have four borders: top, bottom, left, and right. Each border can be independently controlled to be displayed or not, and can have an independent color or style, so the display, color or style of each border can be analyzed and determined separately to determine the corresponding border style attribute. For whether the border is displayed, the attribute indicating whether the border is displayed in the border style attribute can be directly determined based on the data obtained on whether the border is displayed. For the color of the border, similar to the font color, the color format can be converted after the border color is obtained to obtain the color data in the color format supported by the target format as the color attribute in the border style attribute. For the line style of the border, the obtained line style can be mapped to the border line style attribute in the target format based on the pre-established mapping relationship. Taking the export of HTML table to Excel table as an example, the mapping of the above attributes can be implemented according to the following mapping relationship table:
[0114] border-style in HTML border.style in Excel solid thin dotted dotted dashed dashDot double double etc none
[0115] In addition, optionally, according to specific application requirements, other border style attributes may also be parsed and obtained.
[0116] In some embodiments, when parsing each cell, the cell picture information in the cell object attribute of the corresponding cell object can be determined by the following steps: in response to the corresponding cell containing a label related to the picture, the picture data is obtained based on the label; the picture data is converted into picture encoding data supported by the target format; at least based on the picture encoding data, the cell picture information of the cell object is determined. Exemplarily, in the process of traversing each cell, for cells containing labels related to the picture, the cell picture information of the cell object can be determined by the above steps, and for cells that do not contain labels related to the picture, the step of determining the cell picture information can be directly skipped. Exemplarily, the chart attribute of the aforementioned cell object can be an object type, and has attributes such as picture width "width", picture height "height", cell area "range", picture encoding data "base64" in base64 format, etc., wherein the picture encoding data in base64 format is only exemplary, and other picture encoding formats supported by the target format can be adopted according to specific application requirements. Exemplarily, when the tag indicates that the image data is in an expected format, the image data can be directly converted into image coding data supported by the target format, wherein the expected format can refer to a format that can be directly converted into image coding data supported by the target format; otherwise, a picture object in the expected format can be created, the picture data can be drawn in the picture object, and the drawn picture data can be converted into image coding data supported by the target format.
[0117] For example, it can be based on Figure 7 The example flowchart shown is used to determine the cell image information. Figure 7 As shown, taking HTML table as an example, in step 701, the innerHTML attribute of the cell can be read, and in step 702, the innerHTML of the cell can be parsed to determine whether its child elements include canvas or img tags. If included, it indicates that there is a picture in the cell, otherwise, there is no picture. In response to determining that there is no picture in the cell, step 703 can be performed to skip the picture information determination step of the cell; in response to the existence of a picture in the cell, step 704 can be performed to determine whether the tag in the child element is a canvas tag. If not, step 705 can be executed to create a canvas object, draw the picture of the img tag into it, and then call the canvas's toDataURL method to convert the picture data into base64 data. If so, step 706 can be directly executed to convert the picture data into base64 data using the canvas's toDataURL method. In addition, the width, height and cell area information of the picture can also be obtained, and these information are stored in the chart attribute together with the above base64 data as cell picture information.
[0118] Through the various embodiments described above, a large number of parsing and exporting solutions for styles and images are provided. These embodiments can be applied individually, or some or all of these embodiments can be applied in combination, thereby allowing relatively simple and efficient accurate and complete parsing and exporting of the styles of most page tables. More specifically, in addition to implementing a page table exporting solution that can be executed purely on the front end, compared to table exporting solutions such as js-xlsx in related technologies, through some embodiments of the present disclosure, one or more of the following optimizations can be provided: it can support richer style export (such as font style, border style, alignment style, etc.), it can support the export of images in different formats, it can support user configuration to improve the flexibility of controlling which attributes to export, it can support more custom attributes to improve the convenience of controlling some of the exported table attributes, and so on.
[0119] Figure 8 An example block diagram of a page table exporting device 800 according to some embodiments of the present disclosure is schematically shown. Figure 8 As shown, the apparatus 800 includes an acquisition module 810 , a creation module 820 , a determination module 830 and a generation module 840 .
[0120] Specifically, the acquisition module 810 is configured to: acquire the table structure of the page table, wherein the page table includes at least one cell, and the at least one cell forms at least one row and at least one column; the creation module 820 can be configured to: create a table object corresponding to the page table; the determination module 830 can be configured to: traverse the table structure, and determine the table object properties of the table object according to the property description method supported by the target format, wherein the table object properties include at least one property related to the column, row or cell of the page table; the generation module 840 can be configured to: generate a table export file with a target format corresponding to the page table based on at least a part of the table object properties of the table object.
[0121] It should be understood that the apparatus 800 can be implemented in software, hardware, or a combination of software and hardware. Multiple different modules can be implemented in the same software or hardware structure, or one module can be implemented by multiple different software or hardware structures.
[0122] In addition, the apparatus 800 can be used to implement the method 100 described above, and the relevant details have been described in detail above, and for the sake of brevity, they will not be repeated here. Moreover, the apparatus 800 can have corresponding features and advantages as described about the above method.
[0123] Fig. 9 An example block diagram of a computing device 900 according to some embodiments of the present disclosure is schematically shown. Exemplarily, it can represent various types of computing devices that can be used to deploy the apparatus 800 described with reference to the various embodiments described above or can be used to execute the method 100 described with reference to the various embodiments described above.
[0124] As shown, the example computing device 900 includes a processing system 901, one or more computer-readable media 902, and one or more I / O interfaces 903 that are communicatively coupled to each other. Although not shown, the computing device 900 may also include a system bus or other data and command transmission system that couples the various components to each other. The system bus may include any one or combination of different bus structures, such as a memory bus or memory controller, a peripheral bus, a universal serial bus, and / or a processor or local bus utilizing any of a variety of bus architectures, or may also include such as control and data lines.
[0125] Processing system 901 represents the functionality of performing one or more operations using hardware. Thus, processing system 901 is illustrated as including hardware elements 904 that may be configured as processors, functional blocks, etc. This may include implementing application specific integrated circuits in hardware or other logic devices formed using one or more semiconductors. Hardware elements 904 are not limited by the materials from which they are formed or the processing mechanisms employed therein. For example, a processor may be composed of (multiple) semiconductors and / or transistors (e.g., electronic integrated circuits (ICs)). In such a context, processor executable instructions may be electronic executable instructions.
[0126] The computer-readable medium 902 is illustrated as including a memory / storage device 905. The memory / storage device 905 represents a memory / storage device associated with one or more computer-readable media. The memory / storage device 905 may include a volatile storage medium (such as a random access memory (RAM)) and / or a non-volatile storage medium (such as a read-only memory (ROM), a flash memory, an optical disk, a magnetic disk, etc.). The memory / storage device 905 may include a fixed medium (e.g., a RAM, a ROM, a fixed hard drive, etc.) and a removable medium (e.g., a flash memory, a removable hard drive, an optical disk, etc.). Exemplarily, the memory / storage device 905 may be used to store the table structure mentioned in the above embodiment, various attribute data obtained by parsing, exported table files, etc. The computer-readable medium 902 may be configured in various other ways further described below.
[0127] One or more input / output interfaces 903 represent functionality that allows a user to enter commands and information into the computing device 900 and also allows information to be presented to the user and / or sent to other components or devices using various input / output devices. Examples of input devices include a keyboard, a cursor control device (e.g., a mouse), a microphone (e.g., for voice input), a scanner, a touch function (e.g., a capacitive or other sensor configured to detect physical touch), a camera (e.g., a visible or invisible wavelength (such as infrared frequency) can be used to detect motion that does not involve touch as a gesture), a network card, a receiver, and the like. Examples of output devices include a display device (e.g., a display or projector), a speaker, a printer, a tactile response device, a network card, a transmitter, and the like. Exemplarily, in the embodiments described above, an input device can be used to allow a user to select a page table that is desired to be exported, and an output device can be used to allow a user to review an exported table file, and the like.
[0128] The computing device 900 also includes a page table export application 906. The page table export application 906 can be stored as a computer program instruction in the memory / storage device 905. The page table export application 906 can be implemented in conjunction with the processing system 901 and the like with respect to Figure 8 The entire functions or execution of each module of the device 800 described herein are Figure 1 Various embodiments of method 100 are described.
[0129] Various techniques may be described herein in the general context of software, hardware, elements, or program modules. Typically, these modules include routines, programs, objects, elements, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The terms "module," "function," etc., as used herein, generally represent software, firmware, hardware, or a combination thereof. The features of the techniques described herein are platform-independent, meaning that these techniques can be implemented on a variety of computing platforms with a variety of processors.
[0130] An implementation of the described modules and techniques may be stored on or transmitted across some form of computer-readable media. Computer-readable media may include various media accessible by computing device 900. By way of example and not limitation, computer-readable media may include “computer-readable storage media” and “computer-readable signal media”.
[0131] "Computer-readable storage media" refers to media and / or devices capable of persistently storing information, as opposed to simple signal transmissions, carrier waves, or signals themselves, and / or tangible storage devices. Therefore, computer-readable storage media refers to non-signal bearing media. Computer-readable storage media include hardware such as volatile and non-volatile, removable and non-removable media and / or storage devices implemented in a method or technology suitable for storing information (such as computer-executable instructions, data structures, program modules, logic elements / circuits, or other data). Examples of computer-readable storage media may include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical storage devices, hard disks, cassettes, magnetic tape, magnetic disk storage devices or other magnetic storage devices, or other storage devices, tangible media, or articles of manufacture suitable for storing desired information and accessible by a computer.
[0132] "Computer readable signal media" refers to signal bearing media that is configured to send instructions to the hardware of the computing device 900, such as via a network. Signal media typically can embody computer executable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave, data signal or other transport mechanism. Signal media also includes any information transfer media. By way of example and not limitation, signal media include wired media such as a wired network or direct connection and wireless media such as acoustic, RF, infrared and other wireless media.
[0133] As previously described, hardware elements 904 and computer-readable media 902 represent instructions, modules, programmable device logic, and / or fixed device logic implemented in hardware form, which in some embodiments can be used to implement at least some aspects of the technology described herein. Hardware elements can include integrated circuits or systems on a chip, application-specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), complex programmable logic devices (CPLDs), and other implementations in silicon or components of other hardware devices. In this context, hardware elements can be used as processing devices for executing program tasks defined by instructions, modules, and / or logic embodied by hardware elements, as well as hardware devices for storing instructions for execution, such as the computer-readable storage media described previously.
[0134] The aforementioned combination may also be used to implement the various techniques and modules described herein. Therefore, software, hardware or program modules and other program modules may be implemented as one or more instructions and / or logic embodied on some form of computer-readable storage medium and / or by one or more hardware elements 904. The computing device 900 may be configured to implement specific instructions and / or functions corresponding to the software and / or hardware modules. Therefore, for example, by using a computer-readable storage medium and / or hardware element 904 of a processing system, a module may be implemented as a module executable by the computing device 900 as software, at least in part, in hardware. Instructions and / or functions may be executed / operable by, for example, one or more computing devices 900 and / or processing systems 901 to implement the techniques, modules and examples described herein.
[0135] The techniques described herein may be supported by these various configurations of computing device 900 and are not limited to the specific examples of the techniques described herein.
[0136] It should be understood that, for the sake of clarity, embodiments of the present disclosure are described with reference to different functional units. However, it will be apparent that, without departing from the present disclosure, the functionality of each functional unit can be implemented in a single unit, in multiple units, or as a part of other functional units. For example, the functionality that is described as being performed by a single unit can be performed by multiple different units. Therefore, reference to a specific functional unit is only considered as a reference to a suitable unit for providing the described functionality, rather than indicating a strict logical or physical structure or organization. Therefore, the present disclosure can be implemented in a single unit, or can be physically and functionally distributed between different units and circuits.
[0137] The present disclosure provides a computer-readable storage medium on which computer-executable instructions are stored. When the computer-executable instructions are executed, the above-mentioned page table export method is implemented.
[0138] The present disclosure provides a computer program product or a computer program, which includes computer executable instructions, which are stored in a computer-readable storage medium. A processor of a computing device reads the computer executable instructions from the computer-readable storage medium, and the processor executes the computer executable instructions, so that the computing device executes the page table export method provided in the above various embodiments.
[0139] Variations on the disclosed embodiments will be understood and effected by those skilled in the art in practicing the claimed subject matter by studying the drawings, the disclosure and the appended claims. In the claims, the word "comprising" does not exclude other elements or steps, and "a" or "an" does not exclude a plurality. The mere fact that certain measures are recited in mutually different dependent claims does not indicate that a combination of these measures cannot be used to advantage.
Claims
1. A page table export method, comprising: Acquire a table structure of a page table, wherein the page table includes at least one cell, and the at least one cell forms at least one row and at least one column; Creating a table object corresponding to the page table; Traversing the table structure, and determining table object properties of the table object according to a property description method supported by a target format, wherein the table object properties include at least one property related to a column, a row or a cell of the page table; Based on at least a portion of the table object properties of the table object, a table export file having the target format and corresponding to the page table is generated.
2. The method according to claim 1, wherein: The table object attributes include at least one of a column attribute and a row attribute, and, The traversing of the table structure and determining the table object attribute of the table object according to the attribute description method supported by the target format includes at least one of the following items: Traversing the tags related to the columns in the table structure, reading the width of each column in the at least one column, and determining the column attribute based on the read width; The tags related to the rows in the table structure are traversed, the height of each row in the at least one row is read, and the row attribute is determined based on the read height.
3. The method according to claim 1, wherein: The table object properties include merge properties, and, The traversing the table structure and determining the table object attributes of the table object according to the attribute description method supported by the target format includes: Traversing cells in the table structure, wherein for a cell having a row merge attribute or a column merge attribute, based on index data of the cell and the number of rows indicated by the row merge attribute or the number of columns indicated by the column merge attribute of the cell, determining merge information corresponding to the cell, wherein the merge information includes one or more of the following items: a starting row index, an ending row index, a starting column index, and an ending column index; The merge attribute is determined based on merge information corresponding to at least one cell.
4. The method according to claim 1, wherein: The table object properties include cell properties, and, The traversing the table structure and determining the table object attributes of the table object according to the attribute description method supported by the target format includes: Traversing the cells in the table structure, for each cell, creating a cell object corresponding to the cell, and determining the cell object attributes of the created cell object, wherein the cell object attributes include at least one of the following items: cell value, cell format, cell data type, cell style, and cell picture information; The cell attributes are determined based on the cell objects corresponding to the respective cells.
5. The method according to claim 4, wherein: Determining the cell object attribute of the created cell object includes: In response to a cell corresponding to the cell object having a custom cell value, determining a cell value of the cell object as the custom cell value; In response to the cell corresponding to the cell object not having a custom cell value, a value in the cell is extracted as the cell value of the cell object.
6. The method according to claim 4, wherein: Determining the cell object attribute of the created cell object includes: In response to a cell corresponding to the cell object having a custom cell format, determining the cell format of the cell object to be the custom cell format; In response to the cell corresponding to the cell object not having a custom cell format, the cell format of the cell object is determined to be a default cell format.
7. The method according to claim 4, wherein: Determining the cell object attribute of the created cell object includes: In response to a cell corresponding to the cell object having a custom cell data type, determining the cell data type of the cell object to be the custom cell data type; In response to the cell corresponding to the cell object not having a custom cell data type, a type of a cell value of the cell is inferred as the cell data type of the cell object.
8. The method according to claim 4, wherein: Determining the cell object attribute of the created cell object includes: Obtaining, by means of an element style acquisition method supported by the browser, a rendering style of a corresponding cell presented by the browser, wherein the rendering style includes at least one of the following items: a rendering font style, a rendering alignment style, and a rendering border style; Based on the acquired rendering style, the cell style of the cell object is determined according to a mapping relationship between the element style supported by the browser and the element style of the target format.
9. The method according to claim 8, wherein: The rendering style includes a rendering font style, the cell style includes a font style, and, Wherein, the determining the cell style of the cell object based on the acquired rendering style and according to the mapping relationship between the element style supported by the browser and the element style of the target format includes at least one of the following items: Determining a size attribute in the font style based on a font size in the rendered font style; In response to a font name in the rendering font style existing in a font name dictionary supported by the target format, determining a name attribute in the font style based on the font name, otherwise, determining the name attribute in the font style as a default font name; Performing format conversion on the font color in the rendered font style to obtain color data in a color format supported by the target format as a color attribute in the font style; Based on the style attributes in the rendered font style indicating the font thickness, whether it is italic, underlined or struck-through, the bold, italic, underline or strike-through attributes in the font style are determined according to a preset mapping relationship.
10. The method according to claim 8, wherein: The rendering style includes a rendering alignment style, the cell style includes an alignment style, and, Wherein, determining the cell style of the cell object based on the acquired rendering style and according to a mapping relationship between the element style supported by the browser and the element style of the target format includes: Based on the attribute indicating whether to automatically wrap, the horizontal alignment mode or the vertical alignment mode in the rendering alignment style, the automatic wrap, horizontal alignment or vertical alignment attribute in the alignment style is determined according to a preset mapping relationship.
11. The method according to claim 8, wherein: The rendering style includes a rendering border style, the cell style includes a border style, and, Wherein, the determining the cell style of the cell object based on the acquired rendering style and according to the mapping relationship between the element style supported by the browser and the element style of the target format includes at least one of the following items: Performing format conversion on the border color in the rendering border style to obtain color data in a color format supported by the target format as a color attribute in the border style; Based on the attribute indicating the border line style in the rendered border style, a line style attribute in the border style is determined according to a preset mapping relationship.
12. The method according to claim 4, wherein: Determining the cell object attribute of the created cell object includes: In response to the corresponding cell containing a tag related to the picture, obtaining picture data based on the tag; Converting the image data into image encoding data supported by the target format; Based at least on the picture encoding data, cell picture information of the cell object is determined.
13. The method according to claim 12, wherein: The converting the picture data into picture coding data supported by the target format comprises: In response to the tag indicating that the picture data is in an expected format, directly converting the picture data into picture coding data supported by the target format, wherein the expected format is a format that can be directly converted into picture coding data supported by the target format; In response to the tag indicating that the picture data is not in the expected format, a picture object in the expected format is created, the picture data is drawn in the picture object, and the drawn picture data is converted into picture encoding data supported by the target format.
14. The method according to claim 1, wherein: Generating a table export having the target format corresponding to the page table based on at least a portion of the table object attributes of the table object includes: Based on the target format, create a target table object; Mapping at least a portion of the table object properties of the table object to target object properties of the target table object; The table export file is generated based on the target object attributes of the target table object.
15. The method according to any one of claims 1 to 14, wherein: The step of generating a table export file having the target format and corresponding to the page table based on at least a portion of the table object attributes of the table object comprises: Obtaining a user configuration, wherein the user configuration indicates whether to export or not to export at least a portion of table object properties of the table object; According to the user configuration, based on at least a portion of the table object attributes of the table object, a table export file having the target format and corresponding to the page table is generated.
16. The method according to any one of claims 1 to 14, further comprising: In response to the absence of a label associated with a row in the table structure, stopping exporting the page table and reporting an error.
17. A page table exporting device, comprising: An acquisition module is configured to: acquire a table structure of a page table, wherein the page table includes at least one cell, and the at least one cell forms at least one row and at least one column; A creation module is configured to: create a table object corresponding to the page table; A determination module is configured to: traverse the table structure, and determine the table object attribute of the table object according to the attribute description method supported by the target format, wherein the table object attribute includes at least one attribute related to the column, row or cell of the page table; The generation module is configured to: generate a table export file having the target format corresponding to the page table based on at least a part of the table object attributes of the table object.
18. A computing device comprising: a memory configured to store computer-executable instructions; A processor configured to perform the method according to any one of claims 1 to 16 when the computer executable instructions are executed by the processor.
19. A computer-readable storage medium storing computer-executable instructions, which, when executed, perform the method according to any one of claims 1 to 16.
20. A computer program product comprising computer executable instructions, which, when executed by a processor, implement the steps of the method of any one of claims 1 to 16.