Table layout method, device, electronic device and storage medium
By automatically adjusting the row height and column width of table cells, and according to the proportional relationship between the table and the view, the problem of table adjustment in the prior art requires a lot of manual operation, improving the readability and aesthetics of the table.
Patent Information
- Application Number
- CN202111348358.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-15
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2041-11-15
AI Technical Summary
In the prior art, the table adjustment method requires a lot of manual operations and requires the user to have high proficiency, resulting in high user operation complexity and insufficient readability and aesthetics of the table content.
By obtaining the table width and height of cells in the target area, automatically adjust the row height and column width of cells according to the proportional relationship between the table width and the view width, and/or the proportional relationship between the table height and the view height, the row height and column width of cells are simplified by the user's operation steps.
It reduces the operation steps of users to adjust tables, reduces complexity, and improves the aesthetics and readability of table contents.
Smart Images

Figure CN113962193B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of table document typesetting, and in particular to a table typesetting method, device, electronic device and storage medium. Background Art
[0002] As one of the commonly used office applications, tables are widely used, such as calculating data and recording information. In order to make the table beautiful and increase the readability of the table content, you can adjust the format of the cells in the table through various methods.
[0003] In the related art, the cell contents can be fully displayed by adjusting the column width, row height, font, etc. of the table, thereby increasing the readability of the table contents. However, the table adjustment method in the related art requires a lot of manual operations and requires users to have high proficiency. Summary of the invention
[0004] The purpose of the present application is to provide a table layout method, device, electronic device and storage medium for automatic table layout, so as to reduce the operation steps and complexity when the user adjusts the table.
[0005] The present application provides a table typesetting method, comprising:
[0006] Obtain the table width and table height of the table constituted by the cells in the target area; adjust at least one of the row height and column width of the cells in the target area according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height; wherein the view height and the view width are the height and width of the view window, respectively; the view window is a visual window for displaying the contents contained in the cells in the target area.
[0007] Optionally, before adjusting at least one of the row height and column width of the cells in the target area according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height, the method also includes: obtaining the target content of the target cell; the target cell is any cell included in the target area; when the target content is text content, adjusting the target content according to a preset text format, and adjusting the format of the target cell according to the adjusted target content; wherein the text content in the adjusted target cell does not wrap and can be fully displayed; or, when the target content includes image content, adjusting the target content according to a preset image format, and adjusting the format of the target cell according to the adjusted target content; wherein the image in the adjusted target cell can be fully displayed.
[0008] Optionally, adjusting the format of the target cell according to the adjusted target content includes: adjusting the distance between the target content and the border of the target cell according to an area ratio of an area where the adjusted target content is located to an area where the target cell is located.
[0009] Optionally, adjusting at least one of the row height and column width of cells in the target area according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height, includes: when the table width is less than the target width, obtaining a first target ratio corresponding to any target column in the table, and adjusting the column width of the target column by multiplying the first target ratio and the target width as the increase in the column width of the target column; and / or, when the table height is less than the target height, obtaining a second target ratio corresponding to any target row in the table, and adjusting the row height of the target row by multiplying the second target ratio and the target height as the increase in the row height of the target row; wherein the target width is a view width of a first preset ratio; the target height is a view row height of a second preset ratio; the first target ratio is the ratio of the column width of the target column before adjustment to the table width; and the second target ratio is the ratio of the row height of the target row before adjustment to the table height.
[0010] Optionally, adjusting at least one of the row height and column width of cells in the target area according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height, includes: when the table width is greater than the target width and less than the view width, obtaining a third target ratio corresponding to any target column in the target area, and adjusting the column width of the target column by multiplying the third target ratio and the view width as the increase in the column width of the target column; and / or, when the table height is greater than the target height and less than the view width, obtaining a fourth target ratio corresponding to any target row in the target area, and adjusting the row height of the target row by multiplying the fourth target ratio and the view height as the increase in the row height of the target row; wherein the target width is a view width of a first preset ratio; the target height is a view height of a second preset ratio; the third target ratio is a ratio of the column width of the target column before adjustment to the table width; and the fourth target ratio is a ratio of the row height of the target row before adjustment to the table height.
[0011] Optionally, adjusting at least one of the row height and column width of cells in the target area according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height, includes: when the table width is greater than the view width, determining a first adjustment ratio according to the degree to which the table width exceeds the view width; determining a second target column in the target area whose column width is to be adjusted according to the first adjustment ratio; the second target column is a column that ranks high in column width after the target area is sorted according to column width and whose cells do not contain image content; the number of the second target columns is obtained based on the product of the first adjustment ratio and the total number of columns in the target area; adjusting the column width of the second target column and the row height of the second target row according to a first preset adjustment scheme; wherein the second target row is the row to which the cells whose column width is adjusted in the target area belong and whose text in the cells cannot be fully displayed after automatic line break is set; the text in the cells in the adjusted second target row can be fully displayed.
[0012] Optionally, adjusting at least one of the row height and column width of cells in the target area according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height, includes: when the table height is greater than the view height, determining a second adjustment ratio according to the degree to which the table height exceeds the view width; determining a third target row in the target area whose row height needs to be adjusted according to the second adjustment ratio; the third target row is a row that ranks high in row height after sorting the target area according to row height and whose cells do not contain image content; the number of third target rows is obtained based on the product of the second adjustment ratio and the total number of rows in the target area; adjusting the column width of the third target column and the row height of the third target row according to a second preset adjustment scheme; wherein the third target column is the column to which the cells whose row height is adjusted in the target area belong and the text in the cells cannot be fully displayed after automatic line break is set; the text in the cells in the adjusted third target column can be fully displayed.
[0013] Optionally, adjusting at least one of the row height and column width of cells in the target area according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height, includes: when the table width is greater than the view width, adjusting the column width of each column in the target area in descending order of column width; setting the cells in the fourth target row to automatically wrap, and adjusting the row height of the fourth target row until the table width is less than or equal to the view width, and stopping the adjustment; wherein the fourth target row is the row to which the cells whose text cannot be fully displayed after the column width is adjusted in the target area belong; the text in the cells in the adjusted fourth target row can be fully displayed.
[0014] Optionally, adjusting at least one of the row height and column width of cells in the target area according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height, includes: when the table height is greater than the view height, adjusting the row height of each row in the target area in descending order, and adjusting the column width of the fourth target column, until the table height is less than or equal to the view height, and stopping the adjustment; wherein the fourth target column is the column to which the cells in the target area whose text cannot be fully displayed after the row height is adjusted; the text in the cells in the adjusted fourth target column can be fully displayed.
[0015] The present application also provides a table typesetting device, comprising:
[0016] An acquisition module is used to acquire the table width and table height of the table constituted by the cells in the target area; an adjustment module is used to adjust at least one of the row height and column width of the cells in the target area according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height; wherein the view height and the view width are the height and width of the view window respectively; and the view window is a visible window for the contents contained in the cells in the target area.
[0017] Optionally, the acquisition module is also used to acquire the target content of the target cell; the target cell is any cell included in the target area; the adjustment module is also used to adjust the target content according to a preset text format when the target content is text content, and adjust the format of the target cell according to the adjusted target content; wherein the text content in the adjusted target cell does not wrap and can be fully displayed; or, the adjustment module is also used to adjust the target content according to a preset image format when the target content includes image content, and adjust the format of the target cell according to the adjusted target content; wherein the image in the adjusted target cell can be fully displayed.
[0018] Optionally, the adjustment module is specifically configured to adjust the distance between the target content and the border of the target cell according to the adjusted area ratio of the area where the target content is located to the area where the target cell is located.
[0019] Optionally, the acquisition module is also used to acquire a first target ratio corresponding to any target column in the table when the table width is smaller than the target width; the adjustment module is specifically used to adjust the column width of the target column by taking the product of the first target ratio and the target width as the increase in the column width of the target column; and / or, the acquisition module is also used to acquire a second target ratio corresponding to any target row in the table when the table height is smaller than the target height; the adjustment module is specifically used to adjust the row height of the target row by taking the product of the second target ratio and the target height as the increase in the row height of the target row; wherein the target width is a view width of a first preset ratio; the target height is a view row height of a second preset ratio; the first target ratio is the ratio of the column width of the target column before adjustment to the table width; and the second target ratio is the ratio of the row height of the target row before adjustment to the table height.
[0020] Optionally, the acquisition module is further used to acquire a third target ratio corresponding to any target column in the target area when the table width is greater than the target width and less than the view width; the adjustment module is specifically used to adjust the column width of the target column by taking the product of the third target ratio and the view width as the increase in the column width of the target column; and / or, the acquisition module is further used to acquire a fourth target ratio corresponding to any target row in the target area when the table height is greater than the target height and less than the view width; the adjustment module is specifically used to adjust the row height of the target row by taking the product of the fourth target ratio and the view height as the increase in the row height of the target row; wherein the target width is the view width of a first preset ratio; the target height is the view height of a second preset ratio; the third target ratio is the ratio of the column width of the target column before adjustment to the table width; and the fourth target ratio is the ratio of the row height of the target row before adjustment to the table height.
[0021] Optionally, the device also includes: a determination module, which is used to determine a first adjustment ratio according to the extent to which the table width exceeds the view width when the table width is greater than the view width; the determination module is also used to determine a second target column in the target area whose column width is to be adjusted according to the first adjustment ratio; the second target column is a column in the target area that ranks high in column width after sorting by column width and whose cells do not contain image content; the number of second target columns is obtained based on the product of the first adjustment ratio and the total number of columns in the target area; the adjustment module is specifically used to adjust the column width of the second target column and the row height of the second target row according to a first preset adjustment scheme; wherein the second target row is the row to which the cells whose column width is adjusted in the target area and the text in the cells cannot be fully displayed after automatic line break is set; the text in the cells of the adjusted second target row can be fully displayed.
[0022] Optionally, the determination module is used to determine a second adjustment ratio according to the extent to which the table height exceeds the view width when the table height is greater than the view height; the determination module is also used to determine a third target row in the target area whose row height needs to be adjusted according to the second adjustment ratio; the third target row is a row that ranks high in row height after sorting the target area according to row height and whose cells do not contain image content; the number of third target rows is obtained based on the product of the second adjustment ratio and the total number of rows in the target area; the adjustment module is specifically used to adjust the column width of the third target column and the row height of the third target row according to a second preset adjustment scheme; wherein the third target column is the column to which the cells whose row height is adjusted in the target area belong and whose text cannot be fully displayed after automatic line break is set; the text in the cells in the adjusted third target column can be fully displayed.
[0023] Optionally, the adjustment module is specifically used to adjust the width of each column in the target area in descending order when the table width is greater than the view width; set the cells in the fourth target row to automatically wrap, and adjust the row height of the fourth target row until the table width is less than or equal to the view width, and stop adjusting; wherein the fourth target row is the row to which the cells whose text cannot be fully displayed after the column width is adjusted in the target area belong; the text in the cells in the adjusted third target column can be fully displayed.
[0024] Optionally, the adjustment module is specifically used to adjust the row height of each row in the target area in descending order when the table height is greater than the view height, and adjust the column width of the fourth target column until the table height is less than or equal to the view height and stop adjusting; wherein the fourth target column is the column to which the cells whose text cannot be fully displayed after the row height is adjusted in the target area belong; the text in the cells in the adjusted fourth target column can be fully displayed.
[0025] The present application also provides a computer program product, including a computer program / instruction, which implements the steps of any of the table typesetting methods described above when executed by a processor.
[0026] The present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the table typesetting methods described above are implemented.
[0027] The present application also provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any of the table typesetting methods described above are implemented.
[0028] The table layout method, device, electronic device and storage medium provided by the present application can automatically adjust at least one of the row height and column width of the cells in the target area according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height after obtaining the table width and table height of the cells in the target area. This can not only reduce the user's manual operation path for adjusting cells and save terminal operation resources, but also improve the aesthetics and readability of the table content. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions in the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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 paying any creative work.
[0030] Figure 1 It is a flowchart of the table typesetting method provided by this application;
[0031] Figure 2 It is a schematic diagram of table width and height calculation provided by this application;
[0032] Figure 3 It is a structural schematic diagram of the table typesetting device provided by the present application;
[0033] Figure 4 It is a structural schematic diagram of the electronic device provided by this application. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in this application. Obviously, the described embodiments 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 creative work are within the scope of protection of this application.
[0035] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0036] In the related art, when users use tables, due to the limitations of cell size and format, problems such as the content in the cell being covered and the data format in the cell being incorrect may occur, mainly including the following five items:
[0037] a. For table files exported from other applications, the cells are not processed according to the length of the data in the cells, resulting in incomplete data display when the data in the cells is too long, or too much blank space in the cells when the data in the cells is too short.
[0038] b. When the row height and column width of a cell are smaller than the length and height of the cell content, the data format in the cell changes, resulting in data errors or reduced data validity.
[0039] c. When printing a form, the layout of the form on the paper cannot be arranged properly, resulting in paper waste.
[0040] d. When there is too much data in the table, the distance between the text content and the table border is too small, resulting in poor readability of the data.
[0041] e. The amount of table content displayed on the screen varies on screens with different resolutions. When the table content is too much, the user cannot see the table content on one screen, and often needs to slide the mouse wheel up and down, slide the scroll bar left and right, and other operations to view the content outside the screen; when the table content is too little, the table occupies too little area, resulting in unclear table content, and a large area is blank without content, and the screen space is not fully utilized for display.
[0042] Based on the above technical problems existing in the related technology, an embodiment of the present application provides a table typesetting method for automatic typesetting of a table to improve the readability of the table, make the table more beautiful, and reduce the complexity of user operations.
[0043] The table typesetting method provided in the embodiment of the present application is described in detail below through specific embodiments and application scenarios in conjunction with the accompanying drawings.
[0044] like Figure 1 As shown, an embodiment of the present application provides a table layout method, which may include the following steps 101 and 102:
[0045] Step 101: Get the table width and table height of the table formed by the cells in the target area.
[0046] Exemplarily, the cells in the target area are cells in a target table, which may be a table manually created by a user or a table exported by other applications. The target area is an editing area of the target table.
[0047] Exemplarily, the target area may be an area selected by a user, or an area where cells containing content (such as text, pictures, etc.) are located. In the embodiment of the present application, the format of cells in a table in the target area is mainly adjusted.
[0048] Exemplarily, before typeset the target table, it is necessary to determine the area in the target table that needs typeset, that is, the target area, and then obtain the table width and table height formed by the cells in the target area.
[0049] Exemplarily, the table width and table height respectively indicate the total width and total height of all cells in the target area, that is, the table width is the sum of the widths of all cells in any row in the target area, and the table height is the sum of the heights of all cells in any column in the target area.
[0050] For example, Figure 2 As shown, it is a table with 10 rows and 6 columns, wherein the row height of each cell is 15 and the column width is 30. Then the width of the table is 30*6=180, and the height of the table is 15*10=150.
[0051] It is understandable that each cell in a table has a corresponding column width and row height, and without considering merged cells, the column width of each column is the same, and the row height of each row is the same. The row height and column width of the merged cells are the same as the sum of the row heights and column widths of the cells before merging.
[0052] Step 102: According to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height, adjust at least one of the row height and the column width of the cells in the target area.
[0053] The view height and view width are the height and width of the view window, respectively. The view window is a visual window for displaying the contents contained in the cells in the target area.
[0054] For example, after obtaining the width and height of the above table, it is also necessary to determine the size of the view window under the current screen resolution. The view window is a window that displays the table content, that is, the visible area of the table.
[0055] Exemplarily, the view window is determined based on the screen resolution and the window size of the spreadsheet application, and may also be directly obtained through the interface of the spreadsheet application.
[0056] It is understandable that the size of the visible window is different under different screen resolutions. When the table content scaling ratio is 100% and the application window size of the table application is consistent, the higher the screen resolution, the richer the displayed content, and the more table content the view window displays. Similarly, the larger the application window of the table application, the more table content it displays. Therefore, for the convenience of description, the view window in the embodiment of the present application is the visible window of the table content when the window of the table application is maximized at the current screen resolution.
[0057] Exemplarily, after obtaining the above-mentioned table size and view size, at least one of the row height and column width of the cells in the target area can be adjusted according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height. This can not only reduce the user's manual operation path for adjusting cells and save terminal operating resources, but also improve the aesthetics and readability of the table content.
[0058] In a possible implementation, the row height of the cells in the target area can also be adjusted according to the size of the view window. Specifically, the row height of each cell is determined according to the number of cells in the target area and the view height, and the row height of the cell is adjusted according to the determined row height; the column width of each cell is determined according to the number of cells in the target area and the view width, and the column width of the cell is adjusted according to the determined column width.
[0059] Optionally, in an embodiment of the present application, before typeset the table, the cells need to be standardized according to the contents of the cells in the table.
[0060] Exemplarily, before the above step 102, the cell may be adjusted based on the following steps 103 and 104, or steps 103 and 105:
[0061] Step 103: Get the target content of the target cell.
[0062] The target cell is any cell in the target area.
[0063] It should be noted that in the embodiments of the present application, for ease of understanding, specific method steps for performing standardized adjustment on the target cells in the above-mentioned target area are described, and all cells in the above-mentioned target area can be standardized according to the specific steps in the adjustment method of the target cells.
[0064] Step 104: When the target content is text content, adjust the target content according to a preset text format, and adjust the format of the target cell according to the adjusted target content; wherein the text content in the adjusted target cell does not wrap and can be fully displayed.
[0065] Step 105: When the target content includes image content, the target content is adjusted according to a preset image format, and the format of the target cell is adjusted according to the adjusted target content; wherein the image in the adjusted target cell can be fully displayed.
[0066] It can be understood that when the above-mentioned target content includes an image, in order to fully display the image, it is necessary to adjust the size of the image and the position of the image in the cell according to the preset image format. For example, the size of the image is adjusted to 5 cm * 6 cm, and the image is set to be centered, left-aligned or right-aligned in the cell, etc.
[0067] Exemplarily, in the embodiments of the present application, the format of the cell is mainly adjusted according to the three layout modes of "moderate", "compact" and "loose".
[0068] Exemplarily, after adjusting the format of the target content contained in the target cell, in order to achieve the display effects of the three layout methods of "moderate", "compact" and "loose" mentioned above, the distance between the target content and the border of the target cell can be adjusted by adjusting the column width and row height of the cell.
[0069] Exemplarily, adjusting the format of the target cell according to the adjusted target content in the above step 104 or step 105 may include the following steps 104a:
[0070] Step 104a: adjust the distance between the target content and the border of the target cell according to the adjusted area ratio of the target content area to the target cell area.
[0071] Specifically, after setting the centering and automatically adjusting the row height and column width, for the above-mentioned "compact" typesetting method, the row height can be increased by 2 pounds; for the above-mentioned "moderate" typesetting method, the row height can be increased by 6 pounds; for the above-mentioned "loose" typesetting method, the row height can be increased by 14 pounds.
[0072] Exemplarily, in an embodiment of the present application, the format of the text content can be adjusted according to the following preset text formats: the font of the text content is set according to a preset font, the bold and italic settings are retained, the underline, strikethrough, superscript, and subscript settings of the text effects are retained, the indentation set by the user is removed, and it is adjusted to no indentation, center alignment, left alignment, or right alignment, etc.
[0073] For example, the font sizes (in pounds) in the above three typeset modes may be adjusted according to the following Table 1:
[0074] Solution Type title subtitle Additional information Table header / row title Title content Remark Loose 18 14 11 12 11 11 Moderate 16 14 10 11 10 10 compact 16 14 10 11 10 10
[0075] Table 1
[0076] Exemplarily, when the target cell is a cell containing text content, the font size of the text can be adjusted according to the typesetting method in Table 1 above, and after adjusting the font size, the row height and column width of the cell can be adjusted so that it can meet any one of "moderate", "compact" and "loose".
[0077] Exemplarily, the method for adjusting the column width and row height of merged cells may include: for a table that has merged x columns, after adjusting the columns of the merged cells, in the "compact" layout mode, the column width cannot exceed 40x characters; in the "moderate" or "loose" layout modes, the column width cannot exceed 50x.
[0078] Exemplarily, based on the typesetting mode of "moderate", the table may be processed a second time so that the table fits the screen, that is, is displayed on the screen in a size that best fits the screen.
[0079] Exemplarily, for a cell in which a picture is embedded, when the row height and column width of the cell in which the picture is embedded are smaller than the minimum row height and / or column width of each cell corresponding to any of the three layout modes of "moderate", "compact" and "loose", the cell format of the picture is adjusted according to the minimum size specified in the following Table 2:
[0080] Layout Column width (characters) Line height (pts) compact 15 110 Moderate 20 120 Loose 25 150
[0081] Table 2
[0082] Optionally, in an embodiment of the present application, after adjusting the format of the cell according to the above three typesetting methods, the overall layout of the table can also be adjusted based on the following steps.
[0083] For example, when the size of the table is significantly different from the size of the view window, the above step 102 may include the following step 102a1 or step 102a2:
[0084] Step 102a1: when the table width is smaller than the target width, obtain a first target ratio corresponding to any target column in the table, and use the product of the first target ratio and the target width as the increase in the width of the target column to adjust the width of the target column.
[0085] Step 102a2: when the table height is less than the target height, obtain a second target ratio corresponding to any target row in the table, and use the product of the second target ratio and the target height as the increase in the target row height to adjust the target row height.
[0086] The target width is a view width of a first preset ratio, and the target height is a view row height of a second preset ratio. The first target ratio is the ratio of the column width of the target column before adjustment to the table width. The second target ratio is the ratio of the row height of the target row before adjustment to the table height.
[0087] It is understandable that, since the width of the target column is less than or equal to the table width, the value range of the first target ratio is greater than 0 and less than or equal to 1. Similarly, the value range of the second target ratio is also greater than 0 and less than or equal to 1.
[0088] For example, when the table height is less than half of the view height, half of the view height is proportionally distributed to each row of the table. Assume that the original height of each row is h_cell_original[i], the table height is h_table_original, and the view height is H. Then the height of each row of the table after adjustment is h_cell[i] = (h_cell_original[i] / h_table_original)*1 / 2H.
[0089] When the table width is less than half of the view width, half of the view width is proportionally distributed to each column of the table. Assume that the width of each column is w_cell_original[i], the table width is w_table_original, and the view width is W. Then the width of each column of the table after adjustment is w_cell[i] = (w_cell_original[i] / w_table_original)*1 / 2W.
[0090] For example, when the size of the table is smaller than that of the view window, the above step 102 may include the following step 102b1 or step 102b2:
[0091] Step 102b1: when the table width is greater than the target width and less than the view width, obtain the third target ratio corresponding to any target column in the table, and adjust the width of the target column by taking the product of the third target ratio and the view width as the increase of the width of the target column.
[0092] Step 102b2: when the table height is greater than the target height and less than the view width, obtain the fourth target ratio corresponding to any target row in the table, and use the product of the fourth target ratio and the view height as the increase in the target row height to adjust the target row height.
[0093] The target width is the view width of the first preset ratio, the target height is the view row height of the second preset ratio, the third target ratio is the ratio of the column width of the target column before adjustment to the table width, and the fourth target ratio is the ratio of the row height of the target row before adjustment to the table height.
[0094] It is understandable that, since the width of the target column is less than or equal to the table width, the value range of the third target ratio is greater than 0 and less than or equal to 1. Similarly, the value range of the fourth target ratio is also greater than 0 and less than or equal to 1.
[0095] Exemplarily, the first preset ratio and the second preset ratio may be the same or different. For the convenience of description, in the embodiment of the present application, the first preset ratio and the second preset ratio may be described as 50% (i.e., the target width is half of the view width, and the target height is half of the view height). When the table width is greater than half of the view width and less than the view width, or the table height is greater than half of the view height and less than the view height, the column width or row height of the cells in the table may be increased to be the same as the width or height of the view window.
[0096] For example, when the table width is less than the view width but greater than half of the view width, the view width is proportionally distributed to each column of the table. Assume that the column width of each column is w_cell_original[i], the table width is w_table_original, and the view width is W. The adjusted view column width is w_cell[i] = (w_cell_original[i] / w_table)*W.
[0097] When the table height is less than the view height but greater than half of the view height, the view height is proportionally distributed to each row of the table. Let the row height of each row be h_cell[i], the table height be h_table_original, and the view height be H, then the adjusted view height is h_cell[i] = (h_cell[i] / h_table)*H.
[0098] Exemplarily, when the table contents exceed the display range of the view window, the cells can be adjusted using the following two methods.
[0099] Method 1:
[0100] Exemplarily, the above step 102 may include the following steps 102c1 to 102c3:
[0101] Step 102c1: When the table width is greater than the view width, determine a first adjustment ratio according to the extent to which the table width exceeds the view width.
[0102] Exemplarily, the first adjustment ratio can be determined according to the degree to which the table width exceeds the view width, that is, the more the table width exceeds the view width, the more columns whose column widths are to be adjusted. The degree to which the table width exceeds the view width can be determined according to the distance by which the table width exceeds the view width, for example, the greater the distance by which the table width exceeds the view width, the greater the degree to which the table width exceeds the view width; it can also be determined according to the ratio between the distance by which the table width exceeds the view width and the view width, for example, the greater the ratio between the distance by which the table width exceeds the view width and the view width, the greater the degree to which the table width exceeds the view width.
[0103] Step 102c2: Determine a second target column whose column width is to be adjusted in the target area according to the first adjustment ratio.
[0104] The second target columns are columns in the target area that are ranked higher in width after being sorted by column width and whose cells do not contain image content. The number of second target columns is obtained based on the product of the first adjustment ratio and the total number of columns in the target area.
[0105] As an example, the columns with the highest column width ranking and cells containing no image content may be a columns with cells containing no image content and the highest column width ranking, where a is an integer greater than or equal to 1.
[0106] Step 102c3: adjust the column width of the second target column and the row height of the second target row according to the first preset adjustment scheme.
[0107] The second target row is a row to which cells belong whose texts cannot be fully displayed after adjusting the column width and setting automatic line wrap in the target area.
[0108] Exemplarily, the first preset adjustment scheme may be: adjusting the column width of the second target column to a third preset ratio of the current column width, and adjusting the row height of the second target row to a fourth preset ratio of the current row height.
[0109] Exemplarily, in order to reduce the width of the table, the third preset ratio may be a number greater than 0 and less than 1. The fourth preset ratio may be a number greater than 1.
[0110] Exemplarily, the text in the cells of the adjusted second target row can be fully displayed. For example, the product of the third preset ratio and the fourth preset ratio is 1. For example, the third preset ratio can be half, and the fourth preset ratio can be twice, that is, the column width is reduced by half and the row height is doubled. The third preset ratio and the fourth preset ratio can also be other relationships, as long as the text in the cells of the adjusted second target row can be fully displayed.
[0111] For example, when the table width is larger than the view width, it means that all the contents of the table cannot be viewed in the current view window. At this time, the cells with larger column widths in the table need to be adjusted.
[0112] For example, the number of cells whose column widths need to be adjusted can be calculated by the value of the portion of the table width that exceeds the view width, and then the column widths of the corresponding cells can be adjusted so that the table width is less than or equal to the view width, thereby avoiding the situation where the table content is blocked.
[0113] Similarly, referring to the above steps of adjusting the column width first and then adjusting the row height, if the user is sensitive to the table height but not to the table width, you can also adjust the row height first and then adjust the column width.
[0114] Exemplarily, the above step 102 may include the following steps 102c4 to 102c6:
[0115] Step 102c4: When the table height is greater than the view height, determine a second adjustment ratio according to the extent to which the table height exceeds the view height.
[0116] Exemplarily, the second adjustment ratio can be determined based on the degree to which the table height exceeds the view height, that is, the more the table height exceeds the view height, the more rows need to be adjusted. The degree to which the table height exceeds the view height can be determined based on the distance the table height exceeds the view height, for example, the greater the distance the table height exceeds the view height, the greater the degree to which the table height exceeds the view height; it can also be determined based on the ratio between the distance the table height exceeds the view height and the view height, for example, the greater the ratio between the distance the table height exceeds the view height and the view height, the greater the degree to which the table height exceeds the view height.
[0117] Step 102c5, determine the third target row in the target area whose row height needs to be adjusted according to the second adjustment ratio; the third target row is the row in the target area that ranks high in row height after sorting by row height and whose cells do not contain image content; the number of third target rows is obtained based on the product of the second adjustment ratio and the total number of rows in the target area.
[0118] As an example, the above-mentioned rows with high row height ranking and no image content in the cells may be the b rows with no image content in the cells and high row height ranking, where b is an integer greater than or equal to 1.
[0119] Step 102c6: adjust the column width of the third target column and the row height of the third target row according to the second preset adjustment scheme.
[0120] Among them, the third target column is the column to which the cells in the target area belong whose row height is adjusted and whose texts in the cells cannot be fully displayed after automatic line wrap is set; the texts in the cells in the adjusted third target column can be fully displayed.
[0121] Exemplarily, the second preset adjustment scheme may be: adjusting the row height of the third target row to a fifth preset ratio of the current row height, and adjusting the column width of the third target column to a sixth preset ratio of the current column width.
[0122] Exemplarily, in order to reduce the height of the table, the fifth preset ratio may be a number greater than 0 and less than 1. The sixth preset ratio may be a number greater than 1.
[0123] It should be noted that the above steps of adjusting the row height first and then adjusting the column width can refer to the description of the steps of first adjusting the column width and then adjusting the row height in the above steps 102c1 to 102c3. In order to avoid repetition, they will not be repeated here.
[0124] Method 2:
[0125] Exemplarily, the above step 102 may include the following steps 102d1 and 102d2:
[0126] Step 102d1: When the table width is greater than the view width, adjust the width of each column in the target area in descending order.
[0127] Step 102d2: Set the cells in the fourth target row to automatically wrap, and adjust the row height of the fourth target row until the table width is less than or equal to the view width.
[0128] The fourth target row is a row to which cells whose texts cannot be fully displayed after the column width is adjusted in the target area belong.
[0129] It can be understood that in the process of adjusting the width of each column in the target area in order from large to small, the proportional relationship between the table width and the view width can be calculated in real time. When the table width is less than or equal to the view width, it means that all columns of the table can be viewed in the current view. At this time, you can stop adjusting the column width of the cells in the target area.
[0130] It should be noted that the above-mentioned operation steps of adjusting the row height of the fourth target row and the operation steps of setting the cells in the fourth target row to automatically wrap do not need to be distinguished in order, and their execution results are the same.
[0131] Exemplarily, the above-mentioned step 102d1 may specifically include: adjusting the column width of each column in the target area in order from large to small to the seventh preset ratio of the current column width, setting the cells in the fourth target row to automatically wrap and adjusting the row height of the fourth target row to the eighth preset ratio of the current row height, and stopping the adjustment until the table width is less than or equal to the view width.
[0132] Exemplarily, in order to reduce the table width of the table, the seventh preset ratio may be a number greater than 0 and less than 1. The eighth preset ratio may be a number greater than 1.
[0133] Specifically, the text in the cells of the adjusted fourth target row can be fully displayed. For example, the product of the seventh preset ratio and the eighth preset ratio is 1. For example, the seventh preset ratio can be half, and the eighth preset ratio can be twice, that is, the column width is reduced by half and the row height is doubled. The seventh preset ratio and the eighth preset ratio can also be other relations, as long as the text in the cells of the adjusted fourth target row can be fully displayed.
[0134] Exemplarily, when the table width is greater than the view width, the columns in the target area may be sorted according to the width of each column, and columns with larger widths may be adjusted preferentially until the table width is less than or equal to the view width.
[0135] Specifically, for cells that only contain text content, the cell width can be adjusted to half of the original width, and the row height can be adjusted to twice the original height. In this way, when the cell is set to automatically wrap, the cell content can be fully displayed and the table width can be reduced.
[0136] For example, when the table width is greater than the view width, some cells can be folded. First, calculate the column width that exceeds the view, w_redundant = w_table_original-(W-15 characters), where w_table_original is the sum of the estimated lengths of the cell contents in each column after the cell contents in each column are adjusted to one row, and W is the table view width. Secondly, sort the column widths of each column in the table from large to small, and get the value at the 1 / 4 position in the group of column widths, recorded as 1 / 4·rank_w. Start folding the sorted columns from large to small according to the column width. The width of each column is 1 / 4·rank_w, and calculate the value of the column width minus 1 / 4·rank_w, and subtract it from w_redundant until w_redundant is less than or equal to 0. Among them, if the column width of a column greater than 1 / 4 rank_w minus w_redundant is less than 0, the column width is the column width minus w_redundant, and the line break process is stopped; if the calculation has reached the 1 / 4 position after sorting, but the column width at this position minus w_redundant is still greater than 0, then find the value at the 1 / 2 position in the sorted column width, record it as 1 / 2 rank_w, and restart the line break for each column after sorting from large to small. The column width of each column is 1 / 2 rank w, and the value of the column width minus 1 / 2 rank w is calculated and subtracted from w_redundant until w_redundant is less than or equal to 0. After changing the width of each column, the column is broken, the row height after the break is re-estimated, and the alignment of the column is set to left alignment.
[0137] Similarly, referring to the above steps of adjusting the column width first and then adjusting the row height, if the user is sensitive to the table height but not to the table width, you can also adjust the row height first and then adjust the column width.
[0138] Exemplarily, the above step 102 may further include the following step 102d2:
[0139] Step 102d2: When the table height is greater than the view height, adjust the row height of each row in the target area in descending order, and adjust the column width of the fourth target column until the table height is less than or equal to the view height.
[0140] The fourth target column is the column to which the cells whose texts cannot be fully displayed after the row height is adjusted in the target area belong; the texts in the cells in the fourth target column after adjustment can be fully displayed.
[0141] Exemplarily, the above-mentioned step 102d2 may specifically include: adjusting the row height of each row in the target area in descending order to the ninth preset proportion of the current row height, and adjusting the column width of the fourth target column to the tenth preset proportion of the current column width, until the table height is less than or equal to the view height and stops adjusting.
[0142] Exemplarily, in order to reduce the height of the table, the ninth preset ratio may be a number greater than 1. The tenth preset ratio may be a number greater than 0 and less than 1.
[0143] It should be noted that the above steps of adjusting the row height first and then adjusting the column width can refer to the description of the steps of adjusting the column width first and then adjusting the row height in the above step 102d1. In order to avoid repetition, it will not be repeated here.
[0144] Exemplarily, when the table height is greater than the view height, the following steps may be followed to adjust. The above step 102 may include the following steps 102e:
[0145] Step 102e: when the table height is greater than the view height, increase the row height of each row of cells in the target area according to a preset increment.
[0146] For example, when the table height is greater than the view height, the height of each row in the target area can be increased by 2 pounds. On the basis of typesetting in the "moderate" typesetting method, the height of each row can be increased by 2 pounds to increase the spacing between the contents and make the content display clearer.
[0147] The table layout method provided in the embodiment of the present application automatically adjusts the font, font size, font style, row height and column width, alignment and other settings of the table according to the content of the cells in the target area and / or the proportional relationship between the table formed by the cells and the view window, thereby simplifying the user's operation steps and improving the efficiency of the user in arranging the table. The embodiment of the present application includes multiple sets of layout methods for table contents such as font, font size, row height, column width, etc., so that the table arrangement effect meets the different needs of users, improves the visual effect and readability of the table content, and meets the needs of users to view the table content in various scenarios.
[0148] It should be noted that the table layout method provided in the embodiment of the present application can be executed by a table layout device, or a control module in the table layout device for executing the table layout method. In the embodiment of the present application, the table layout device provided in the embodiment of the present application is described by taking the table layout device executing the table layout method as an example.
[0149] It should be noted that, in the embodiments of the present application, the table layout methods shown in the above-mentioned method drawings are all illustrated by taking one of the drawings in the embodiments of the present application as an example. In specific implementation, the table layout methods shown in the above-mentioned method drawings can also be implemented in combination with any other drawings that can be combined as shown in the above-mentioned embodiments, which will not be described in detail here.
[0150] The table typesetting device provided in the present application is described below, and the table typesetting method described below and above can be referenced to each other.
[0151] Figure 3 A schematic diagram of the structure of a table typesetting device provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, specifically including:
[0152] The acquisition module 301 is used to obtain the table width and table height of the table constituted by the cells in the target area; the adjustment module 302 is used to adjust at least one of the row height and column width of the cells in the target area according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height; wherein the view height and view width are the height and width of the view window respectively; the view window is a visible window for the contents contained in the cells in the target area.
[0153] Optionally, the acquisition module 301 is also used to acquire the target content of the target cell; the target cell is any cell included in the target area; the adjustment module 302 is also used to adjust the target content according to a preset text format when the target content is text content, and adjust the format of the target cell according to the adjusted target content; wherein the text content in the adjusted target cell does not wrap and can be fully displayed; or, the adjustment module 302 is also used to adjust the target content according to a preset image format when the target content includes image content, and adjust the format of the target cell according to the adjusted target content; wherein the image in the adjusted target cell can be fully displayed.
[0154] Optionally, the adjustment module 302 is specifically configured to adjust the distance between the target content and the border of the target cell according to the adjusted area ratio of the area where the target content is located to the area where the target cell is located.
[0155] Optionally, the acquisition module 301 is also used to acquire a first target ratio corresponding to any target column in the table when the table width is less than the target width; the adjustment module 302 is specifically used to adjust the column width of the target column by taking the product of the first target ratio and the target width as the increase in the column width of the target column; and / or, the acquisition module 301 is also used to acquire a second target ratio corresponding to any target row in the table when the table height is less than the target height; the adjustment module 302 is specifically used to adjust the row height of the target row by taking the product of the second target ratio and the target height as the increase in the row height of the target row; wherein the target width is a view width of a first preset ratio; the target height is a view row height of a second preset ratio; the first target ratio is the ratio of the column width of the target column before adjustment to the table width; and the second target ratio is the ratio of the row height of the target row before adjustment to the table height.
[0156] Optionally, the acquisition module 301 is also used to acquire a third target ratio corresponding to any target column in the target area when the table width is greater than the target width and less than the view width; the adjustment module 302 is specifically used to adjust the column width of the target column by taking the product of the third target ratio and the view width as the increase in the column width of the target column; and / or, the acquisition module 301 is also used to acquire a fourth target ratio corresponding to any target row in the target area when the table height is greater than the target height and less than the view width; the adjustment module 302 is specifically used to adjust the row height of the target row by taking the product of the fourth target ratio and the view height as the increase in the row height of the target row; wherein the target width is the view width of a first preset ratio; the target height is the view height of a second preset ratio; the third target ratio is the ratio of the column width of the target column before adjustment to the table width; and the fourth target ratio is the ratio of the row height of the target row before adjustment to the table height.
[0157] Optionally, the device also includes: a determination module 303, which is used to determine a first adjustment ratio according to the extent to which the table width exceeds the view width when the table width is greater than the view width; the determination module 303 is also used to determine a second target column in the target area whose column width is to be adjusted according to the first adjustment ratio; the second target column is a column in the target area that ranks high in column width after sorting by column width and whose cells do not contain image content; the number of second target columns is obtained based on the product of the first adjustment ratio and the total number of columns in the target area; an adjustment module 302, which is specifically used to adjust the column width of the second target column and the row height of the second target row according to a first preset adjustment scheme; wherein the second target row is the row to which the cells whose column width is adjusted in the target area belong and whose text cannot be fully displayed after automatic line break is set; the text in the cells of the adjusted second target row can be fully displayed.
[0158] Optionally, the determination module 303 is used to determine the second adjustment ratio according to the degree to which the table height exceeds the view width when the table height is greater than the view height; the determination module 303 is also used to determine the third target row in the target area whose row height needs to be adjusted according to the second adjustment ratio; the third target row is the row in the target area that ranks high after sorting by row height and whose cells do not contain image content; the number of third target rows is obtained based on the product of the second adjustment ratio and the total number of rows in the target area; the adjustment module 302 is specifically used to adjust the column width of the third target column and the row height of the third target row according to the second preset adjustment scheme; wherein the third target column is the column to which the cells in the target area whose row height is adjusted and the text in the cells cannot be fully displayed after automatic line break is set; the text in the cells in the adjusted third target column can be fully displayed.
[0159] Optionally, the adjustment module 302 is specifically used to adjust the width of each column in the target area in descending order when the table width is greater than the view width; set the cells in the fourth target row to automatically wrap, and adjust the row height of the fourth target row until the table width is less than or equal to the view width, and stop adjusting; wherein the fourth target row is the row to which the cells whose text cannot be fully displayed after the column width is adjusted in the target area belong; and the text in the cells in the adjusted third target column can be fully displayed.
[0160] Optionally, the adjustment module 302 is specifically used to adjust the row height of each row in the target area in descending order when the table height is greater than the view height, and adjust the column width of the fourth target column until the table height is less than or equal to the view height, and stop adjusting; wherein the fourth target column is the column to which the cells whose texts cannot be fully displayed after the row height is adjusted in the target area belong; the texts in the cells in the adjusted fourth target column can be fully displayed.
[0161] The table layout device provided by the present application automatically adjusts the table's font, font size, font style, row height and column width, alignment and other settings according to the content of the cells in the target area and / or the proportional relationship between the table formed by the cells and the view window, thereby simplifying the user's operation steps and improving the user's efficiency in arranging tables. Through the designer's research and analysis of tables in various scenarios, four sets of settings for fonts, font sizes, row heights, column widths and other contents under typesetting methods are summarized, so that the table arrangement effect meets the different needs of users, improves the visual effect and readability of the table content, and meets the needs of users to view the table content in various scenarios.
[0162] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the table typesetting method, which includes: obtaining the table width and table height of the table formed by the cells in the target area; adjusting at least one of the row height and column width of the cells in the target area according to the proportional relationship between the table width and the view width and the proportional relationship between the table height and the view height; wherein the view height and the view width are the height and width of the view window respectively; the view window is a visual window for displaying the contents contained in the cells in the target area.
[0163] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0164] On the other hand, the present application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the table typesetting method provided by the above methods, and the method includes: obtaining the table width and table height of the table constituted by the cells in the target area; adjusting at least one of the row height and column width of the cells in the target area according to the proportional relationship between the table width and the view width and the proportional relationship between the table height and the view height; wherein the view height and view width are the height and width of the view window, respectively; the view window is a visual window for displaying the contents contained in the cells in the target area.
[0165] On the other hand, the present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the above-mentioned table typesetting methods, the method comprising: obtaining the table width and table height of the table constituted by the cells in the target area; adjusting at least one of the row height and column width of the cells in the target area according to the proportional relationship between the table width and the view width and the proportional relationship between the table height and the view height; wherein the view height and view width are the height and width of the view window, respectively; and the view window is a visual window for displaying the contents contained in the cells in the target area.
[0166] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.
[0167] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.
[0168] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A table typesetting method, characterized in that: include: Get the table width and table height of the table formed by the cells in the target area; According to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height, adjusting at least one of the row height and the column width of the cells in the target area; The view height and the view width are the height and width of the view window respectively; the view window is used to display the content contained in the cells in the target area; Wherein, adjusting at least one of the row height and the column width of the cells in the target area according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height, includes at least one of the following: When the table width is smaller than the target width, a first target ratio corresponding to any target column in the table is obtained, and the product of the first target ratio and the target width is used as the increase in the width of the target column to adjust the column width of the target column; and / or, when the table height is smaller than the target height, a second target ratio corresponding to any target row in the table is obtained, and the product of the second target ratio and the target height is used as the increase in the height of the target row to adjust the row height of the target row; wherein the target width is a first preset ratio of the view width; the target height is a second preset ratio of the view row height; the first target ratio is the ratio of the column width of the target column before adjustment to the table width; the second target ratio is the ratio of the row height of the target row before adjustment to the table height; When the table width is greater than the target width and less than the view width, a third target ratio corresponding to any target column in the target area is obtained, and the product of the third target ratio and the view width is used as the increase in the width of the target column to adjust the column width of the target column; and / or, when the table height is greater than the target height and less than the view width, a fourth target ratio corresponding to any target row in the target area is obtained, and the product of the fourth target ratio and the view height is used as the increase in the height of the target row to adjust the row height of the target row; wherein the target width is the view width of a first preset ratio; the target height is the view height of a second preset ratio; the third target ratio is the ratio of the column width of the target column before adjustment to the table width; and the fourth target ratio is the ratio of the row height of the target row before adjustment to the table height; In the case where the table width is greater than the view width, a first adjustment ratio is determined according to the extent to which the table width exceeds the view width; a second target column whose column width is to be adjusted in the target area is determined according to the first adjustment ratio; the second target column is a column in the target area that ranks high in column width after being sorted by column width and whose cells do not contain image content; the column width of the second target column and the row height of the second target row are adjusted according to a first preset adjustment scheme; wherein the second target row is a row to which cells whose column width is adjusted in the target area and whose texts in the cells cannot be fully displayed after automatic line wrap is set; the texts in the cells in the adjusted second target row can be fully displayed; In the case where the table height is greater than the view height, a second adjustment ratio is determined according to the extent to which the table height exceeds the view height; a third target row in the target area whose row height is to be adjusted is determined according to the second adjustment ratio; the third target row is a row that ranks high in row height after the target area is sorted by row height and whose cells do not contain image content; the column width of the third target column and the row height of the third target row are adjusted according to the second preset adjustment scheme; wherein the third target column is a column to which cells whose row height is adjusted in the target area and whose texts in the cells cannot be fully displayed after automatic line wrap is set belong; the texts in the cells in the adjusted third target column can be fully displayed; When the table width is greater than the view width, the width of each column is adjusted in order from the largest to the smallest column width in the target area; the cells in the fourth target row are set to wrap automatically, and the row height of the fourth target row is adjusted until the table width is less than or equal to the view width, and the adjustment is stopped; wherein the fourth target row is the row to which the cells whose text cannot be fully displayed after the column width is adjusted in the target area belong; the text in the cells in the adjusted fourth target row can be fully displayed; When the table height is greater than the view height, the row height of each row is adjusted in descending order according to the row heights in the target area, and the column width of the fourth target column is adjusted until the adjustment is stopped when the table height is less than or equal to the view height; wherein the fourth target column is the column to which the cells whose texts cannot be fully displayed after the row heights are adjusted in the target area belong; the texts in the cells in the adjusted fourth target column can be fully displayed.
2. The method according to claim 1, characterized in that Before adjusting at least one of the row height and the column width of the cells in the target area according to the proportional relationship between the table width and the view width, and / or the proportional relationship between the table height and the view height, the method further includes: Obtaining target content of a target cell; the target cell is any cell in the cells included in the target area; In the case where the target content is text content, the target content is adjusted according to a preset text format, and the format of the target cell is adjusted according to the adjusted target content; wherein the text content in the adjusted target cell does not wrap and can be fully displayed; or, In the case that the target content includes image content, the target content is adjusted according to a preset image format, and the format of the target cell is adjusted according to the adjusted target content; wherein the image in the adjusted target cell can be fully displayed.
3. The method according to claim 2, characterized in that The adjusting the format of the target cell according to the adjusted target content includes: The distance between the target content and the border of the target cell is adjusted according to the adjusted area ratio of the area where the target content is located to the area where the target cell is located.
4. The method according to claim 1, characterized in that The number of the second target columns is obtained based on the product of the first adjustment ratio and the total number of columns in the target area.
5. The method according to claim 1, characterized in that The number of the third target rows is obtained based on the product of the second adjustment ratio and the total number of rows in the target area.
6. A table layout device, characterized in that: The device comprises: An acquisition module is used to obtain the width and height of the table formed by the cells in the target area; An adjustment module, configured to adjust at least one of a row height and a column width of cells in the target area according to a proportional relationship between a width of the table and a width of the view, and / or a proportional relationship between a height of the table and a height of the view; The view height and the view width are the height and width of the view window respectively; the view window is a visual window for displaying the contents contained in the cells of the target area; The adjustment module is specifically configured to obtain a first target ratio corresponding to any target column in the table when the table width is smaller than the target width, and adjust the width of the target column by taking the product of the first target ratio and the target width as the increase in the width of the target column; and / or, The adjustment module is specifically configured to obtain a second target ratio corresponding to any target row in the table when the table height is less than the target height, and adjust the height of the target row by taking the product of the second target ratio and the target height as the increase in the height of the target row; Wherein, the target width is the view width of the first preset ratio; the target height is the view row height of the second preset ratio; the first target ratio is the ratio of the column width of the target column before adjustment to the table width; the second target ratio is the ratio of the row height of the target row before adjustment to the table height; The adjustment module is specifically used to obtain a third target ratio corresponding to any target column in the target area when the table width is greater than the target width and less than the view width, and adjust the width of the target column by taking the product of the third target ratio and the view width as the increase in the width of the target column; and / or, The adjustment module is specifically configured to obtain a fourth target ratio corresponding to any target row in the target area when the table height is greater than the target height and less than the view width, and adjust the height of the target row by taking the product of the fourth target ratio and the view height as an increase in the height of the target row; Wherein, the target width is the view width of the first preset ratio; the target height is the view height of the second preset ratio; the third target ratio is the ratio of the column width of the target column before adjustment to the table width; the fourth target ratio is the ratio of the row height of the target row before adjustment to the table height; The adjustment module is specifically configured to determine a first adjustment ratio according to the extent to which the table width exceeds the view width when the table width is greater than the view width; The adjustment module is specifically used to determine a second target column whose column width is to be adjusted in the target area according to the first adjustment ratio; the second target column is a column in the target area that ranks high in column width after being sorted by column width and whose cells do not contain image content; The adjustment module is specifically configured to adjust the column width of the second target column and the row height of the second target row according to a first preset adjustment scheme; The second target row is a row to which cells in which the column width is adjusted in the target area and the text in the cells cannot be fully displayed after the automatic line break is set; the text in the cells in the adjusted second target row can be fully displayed; The adjustment module is specifically configured to determine a second adjustment ratio according to the extent to which the height of the table exceeds the height of the view when the height of the table is greater than the height of the view; The adjustment module is specifically configured to determine a third target row in the target area whose row height is to be adjusted according to the second adjustment ratio; the third target row is a row in the target area that ranks high after being sorted by row height and whose cells do not contain image content; The adjustment module is specifically configured to adjust the column width of the third target column and the row height of the third target row according to a second preset adjustment scheme; The third target column is a column in the target area to which cells whose row height is adjusted and whose texts cannot be fully displayed after automatic line wrap is set belong; the texts in the cells in the adjusted third target column can be fully displayed; The adjustment module is specifically used to adjust the width of each column in the target area in descending order when the table width is greater than the view width; The adjustment module is specifically used to set the cells in the fourth target row to automatically wrap, and adjust the row height of the fourth target row until the table width is less than or equal to the view width and stops adjusting; The fourth target row is a row in which cells whose text cannot be fully displayed after the column width is adjusted in the target area belong; the text in the cells in the fourth target row after adjustment can be fully displayed; The adjustment module is specifically used to adjust the row height of each row in the target area in descending order of row height when the table height is greater than the view height, and adjust the column width of the fourth target column, and stop adjusting when the table height is less than or equal to the view height; The fourth target column is the column to which the cells whose texts cannot be fully displayed after the row height is adjusted in the target area belong; the texts in the cells in the adjusted fourth target column can be fully displayed.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the table layout method according to any one of claims 1 to 5 are implemented.
8. An electronic device comprising a processor and a memory storing program instructions, characterized in that: The processor is configured to execute the table layout method according to any one of claims 1 to 5 when running the program instructions.
Citation Information
Patent Citations
Method and equipment for regulating column width of table
CN105094622A
Method and device for customizing form control, and electronic equipment
CN107066439A
Table typesetting method and device, computer equipment and readable storage medium
CN110929487A
Method, device and equipment for realizing adaptation of cells and pictures
CN112784551A