Detailed Description
To make the purpose, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be clearly and completely described below with reference to the drawings in the present application, and it is obvious that the described embodiments are some, but not all embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms first, second and the like in the description and in the claims of the present application are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that embodiments of the application may be practiced in sequences other than those illustrated or described herein, and that the terms "first," "second," and the like are generally used herein in a generic sense and do not limit the number of terms, e.g., the first term can be one or more than one. In addition, "and/or" in the specification and claims means at least one of connected objects, a character "/" generally means that a preceding and succeeding related objects are in an "or" relationship.
In the related art, when a user uses a table, due to the limitations of the size and the format of a cell, the problems that the content in the cell is covered, the data format in the cell is wrong, and the like occur, and the method mainly comprises the following five items:
a. for the table files derived by other applications, the relevant processing of adapting the cells according to the data length in the cells is not carried out, so that the problems that the data in the cells are not displayed completely when the data in the cells are too long, or the cells are too blank when the data in the cells are too short are caused, and the like.
b. When the row height and column width of a cell are smaller than the length and height of the cell contents, the data format in the cell changes, resulting in data errors or reduced data validity.
c. When the form is printed, the layout of the form on the paper cannot be reasonably arranged, so that the paper is wasted.
d. When the table data is too much, the distance between the text content and the table frame is too small, so that the readability of the data is poor.
e. In screens with different resolutions, the amount of the table contents displayed in the screens is different. When the table content is too much, the user cannot see the table content in one screen, and often needs to slide a mouse wheel up and down, slide a scroll bar left and right, and the like to check the content outside the one screen; when the table content is too small, the table occupies too small area, so that the table content is unclear, and a large number of areas are blank and have no content, so that the screen space is not fully utilized for display.
Based on the above technical problems in the related art, the embodiments of the present application provide a form layout method for automatically laying out a form to improve readability of the form, make the form more beautiful, and reduce operation complexity of a user.
The following describes in detail the table layout method provided in the embodiment of the present application with reference to the drawings and specific embodiments and application scenarios thereof.
As shown in fig. 1, a table layout method provided in an embodiment of the present application may include the following steps 101 and 102:
step 101, obtaining the table width and the table height of a table formed by the cells in the target area.
The cells of the target area are cells in a target table, which may be a table created manually by a user or a table derived by other applications. The target area is an editing area of the target table.
For example, the target area may be an area selected by the user, or may be an area where a cell containing content (e.g., text, picture, etc.) is located. In the embodiment of the present application, the format of the cells in the table in the target area is mainly adjusted.
For example, before typesetting the target table, the region in the target table that needs to be typeset, i.e., the target region, needs to be determined. And then, acquiring the width and height of the table formed by the cells in the target area.
Illustratively, the table width and the table height indicate the total width and the total height of all cells in the target area, respectively, i.e., 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.
For example, as shown in fig. 2, a table with 10 rows and 6 columns is provided, where the height of each cell is 15, the width of the column is 30 × 6 — 180, and the height of the table is 15 × 10 — 150.
It will be appreciated that the cells in the table each have a corresponding column width and row height, and that regardless of the consolidated cell, the column width of the cells in each column is the same, as is the row height of the cells in each row. The row height and column width of the merged cell are the same as the sum of the row heights and column widths of the cells before merging.
And 102, adjusting at least one of the row height and the column width of the cells of the target area according to the proportional relation between the table width and the view width and/or the proportional relation between the table height and the view height.
Wherein, the view height and the view width are respectively the height and the width of the view window. The view window is a visual window for displaying the content contained in the cells in the target area.
After obtaining the width and height of the table, the size of a view window at the current screen resolution needs to be determined, where the view window is a window for displaying the table content, that is, a visible area of the table.
Illustratively, the view window is determined based on the resolution of the screen and the window size of the form application, and may also be directly obtained through an interface of the form application.
It can be understood that, the sizes of the visual windows are different under different screen resolutions, and in the case that the table content scaling is 100% and the application windows of the table application are consistent in size, the higher the screen resolution is, the richer the displayed content is, and the more the table content is displayed by the view window. Similarly, the larger the application window of the form application, the more form content it displays. Therefore, for convenience of description, the view window in the embodiment of the present application is a visual window of the table content when the window of the table application is maximized at the current screen resolution.
Illustratively, after the table size and the view size are obtained, at least one of the row height and the column width of the cell in the target area may 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, so that the operation path of the cell manually adjusted by the user may be reduced, the operation resources of the terminal may be saved, and the aesthetic degree and readability of the table content may be improved.
In a possible implementation manner, the row height of the cell in the target area may be further adjusted according to the size of the view window. Specifically, determining the row height of each cell according to the number of the cells in the target area and the view height, and adjusting the row height of the cells according to the determined row height; and determining the column width of each cell according to the number of the cells in the target area and the view width, and adjusting the column width of the cells according to the determined column width.
Optionally, in this embodiment of the present application, before typesetting the table, the cells need to be normalized according to the contents of the cells in the table.
Illustratively, before the above step 102, the cells may be adjusted based on the following steps 103 and 104, or steps 103 and 105:
and 103, acquiring the target content of the target cell.
The target cell is any one of cells included in the target area.
In the embodiment of the present application, for convenience of understanding, a specific method step of performing the standardized adjustment on the target cell in the target area is described, and all the cells in the target area may be subjected to the standardized adjustment according to the specific step in the adjustment method of the target cell.
Step 104, under the condition that the target content is the 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; and the text content in the adjusted target cell is not rewound and can be completely displayed.
Step 105, under the condition that the target content comprises 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; and the adjusted image in the target cell can be completely displayed.
It is understood that, in the case where the target content includes an image, in order to completely display the image, the image needs to be resized according to a preset image format and a position within a cell, for example, the image is resized to 5 cm by 6 cm, the image is arranged to be centered, left aligned, right aligned, or the like in the cell.
Illustratively, in the embodiment of the application, the formats of the cells are mainly adjusted according to three typesetting modes, namely "moderate", "compact" and "loose".
For example, after the format of the target content contained in the target cell is adjusted, in order to achieve the display effects of the three typesetting modes of "moderate", "compact", and "loose", the distance between the target content and the border of the target cell may be adjusted by adjusting the column width and the row height of the cell.
For example, the adjusting the format of the target cell according to the adjusted target content in step 104 or step 105 may include the following steps 104 a:
and 104a, adjusting the distance between the target content and the frame of the target cell according to the area ratio of the area where the target content is located to the area where the target cell is located after adjustment.
Specifically, after centering and automatic adjustment of the line height and column width, the line height can be increased by 2 pounds for the "compact" layout mode described above; for the "medium" layout, the height may be increased by 6 pounds; for the "loose" layout approach described above, the line height may be increased by 14 pounds.
For example, in the embodiment of the present application, the format of the text content may be adjusted according to the following preset text format: the method comprises the steps of setting the font of text content according to the preset font, keeping the thickening and inclining settings, keeping the underline, strikethrough, superscript and subscript settings of the character effect, removing indentation set by a user, and adjusting to no indentation, centered alignment, left alignment or right alignment and the like.
For example, the font sizes (unit: pound) of the above three typesetting modes can be adjusted according to the following table 1:
type of scenario
|
Title
|
Subtitle
|
Supplementary information
|
Header/line mark
|
Title content
|
Remarks for note
|
Loose and comfortable
|
18
|
14
|
11
|
12
|
11
|
11
|
Is moderate
|
16
|
14
|
10
|
11
|
10
|
10
|
Is compact and compact
|
16
|
14
|
10
|
11
|
10
|
10 |
TABLE 1
For example, in the case where the target cell is a cell containing text content, the font size of the text may be adjusted according to the typesetting manner in table 1, and after the font size is adjusted, the height and column width of the cell are adjusted so that any one of "moderate", "compact", and "loose" can be satisfied.
Illustratively, the column width and row height adjustment method for the merged cells may include: for the table with x columns, after the columns of the merging cells are adjusted, the column width cannot exceed 40x characters in a compact typesetting mode, and the column width cannot exceed 50x in a moderate or loose typesetting mode.
For example, the table may be secondarily processed on the basis of the "moderate" layout manner, so that the table fits to the screen, i.e., is displayed in the screen in the size most suitable for the screen.
For example, for the cells embedded in the picture, when the column width of the cell row height of the embedded picture is less than the minimum row height of each cell corresponding to any of the three typesetting modes, namely "medium", "compact" and "loose", and/or the column width, the picture is subjected to cell format adjustment according to the minimum size specified in the following table 2:
typesetting mode
|
Column width (character)
|
High (pound)
|
Is compact and compact
|
15
|
110
|
Is moderate
|
20
|
120
|
Loose and comfortable
|
25
|
150 |
TABLE 2
Optionally, in this embodiment of the application, after the format of the cell is adjusted according to the three typesetting manners, the overall layout of the table may be adjusted based on the following steps.
For example, for the case that the difference between the size of the table and the view window is large, the step 102 may include the following steps 102a1 or 102a 2:
step 102a1, when the table width is smaller than the target width, acquiring a first target ratio corresponding to any target column in the table, and adjusting the column width of the target column by taking the product of the first target ratio and the target width as the amplification of the column width of the target column.
Step 102a2, when the table height is smaller 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 taking the product of the second target ratio and the target height as the increase of the row height of the target row.
The target width is a view width of a first preset proportion, and the target height is a view height of a second preset proportion. The first target ratio is a ratio of a column width before the target column adjustment to a table width. The second target ratio is a ratio of the line height before the target line is adjusted to the table height.
It is understood that, since the width of the target column is smaller than or equal to the table width, the value range of the first target ratio is greater than 0 and smaller 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.
For example, when the table height is less than half the view height, half the view height is apportioned to each row of the table. Assuming 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, the adjusted row height H _ cell [ i ] of each row of the table is (H _ cell _ original [ i ]/H _ table _ original) 1/2H.
When the table width is less than half the view width, half the view width is proportionally assigned to each column of the table. Assuming that the width of each row is W _ cell _ original [ i ], the table width is W _ table _ original, and the view width is W, the adjusted row width W _ cell [ i ] of each row of the table is (W _ cell _ original [ i ]/W _ table _ original) 1/2W.
For example, for the case that the difference between the size of the table and the view window is small, the step 102 may include the following step 102b1 or step 102b 2:
step 102b1, when the table width is greater than the target width and smaller than the view width, acquiring a third target ratio corresponding to any target column in the table, and adjusting the column width of the target column by taking the product of the third target ratio and the view width as the amplification of the target column width.
Step 102b2, when the table height is greater than the target height and smaller than the view width, obtaining a fourth target ratio corresponding to any target row in the table, and taking the product of the fourth target ratio and the view height as the increase of the target row height to adjust the row height of the target row.
The target width is a view width of a first preset proportion, and the target height is a view height of a second preset proportion. The third target ratio is a ratio of a column width before the target column adjustment to a table width, and the fourth target ratio is a ratio of a line height before the target row adjustment to a table height.
It is understood that, since the width of the target column is smaller than or equal to the table width, the value range of the third target ratio is greater than 0 and smaller 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.
For example, the first preset ratio and the second preset ratio may be the same or different. For convenience of description, in the embodiment of the present application, the first preset ratio and the second preset ratio may be 50% (that is, the target width is one half of the view width, and the target height is one half of the view height). When the table width is greater than one-half of the view width and less than the view width, or the table height is greater than one-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.
For example, when the table width is less than the view width but greater than half the view width, the view width is proportionally assigned to each column of the table. Assuming 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.
When the table height is less than the view height but greater than half the view height, the view height is scaled 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 be H _ cell [ i ] (H _ cell [ i ]/H _ table) × H.
For example, in the case where the table content is beyond the display range of the view window, the cells may be adjusted by the following two methods.
The method comprises the following steps:
illustratively, the step 102 may include the following steps 102c1 to 102c 3:
step 102c1, in case the table width is larger than the view width, determines a first adjustment ratio depending on how much the table width exceeds the view width part.
For example, the first adjustment ratio may be determined according to the extent to which the table width exceeds the view width, that is, the more the table width exceeds the view width, the more the number of columns of the column width to be adjusted. The degree that the table width exceeds the view width can be determined according to the distance that the table width exceeds the view width, for example, the larger the distance that the table width exceeds the view width, the larger the degree that the table width exceeds the view width is characterized; the table width may also be determined according to the ratio between the distance exceeding the view width and the view width, for example, the larger the ratio between the distance exceeding the view width and the view width, the larger the degree of exceeding of the view width by the table width is characterized.
And step 102c2, determining a second target column of the column width to be adjusted in the target area according to the first adjustment proportion.
The second target column is a column which is ranked in the target area according to the column widths, is higher in column width ranking and does not contain image content in the unit cell. The number of second target columns is obtained based on a product of the first adjustment ratio and the total number of columns in the target area.
As an example, the column with the column width ranking at the top and the cell not containing the image content may be a columns with the column width ranking at the top and the cell not containing the image content, where a is an integer greater than or equal to 1.
Step 102c3, 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.
And adjusting the column width in the second target behavior target area and setting the line to which the cell which cannot be completely displayed by the text in the cell after automatic line feed belongs.
Illustratively, the first preset adjustment scheme may be: and adjusting the column width of the second target column to be a third preset proportion of the current column width, and adjusting the row height of the second target row to be a fourth preset proportion of the current row height.
For example, in order to reduce the table 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.
Illustratively, the text within the cells in the adjusted second target row can be displayed in its entirety. For example, the product of the third predetermined ratio and the fourth predetermined ratio is 1, for example, the third predetermined ratio may be half, and the fourth predetermined ratio may be twice, that is, the column width is reduced by half, and the row height is increased by one time. The third preset proportion and the fourth preset proportion may be in other relations as long as the adjusted text in the cells in the second target line can be completely displayed.
For example, when the width of the table is larger than the width of the view, it means that all contents of the table cannot be viewed in the current view window, and in this case, the cells with larger column width in the table need to be adjusted.
For example, the number of cells of the column width to be adjusted may be calculated by a numerical value of a portion of the table width exceeding the view width, and then the column width of the corresponding cell is adjusted, so that the table width is smaller than or equal to the view width, and a situation that the table content is blocked is avoided.
Similarly, referring to the step of adjusting the column width first and then adjusting the row height, the row height may be adjusted first and then the column width may be adjusted under the condition that the user is sensitive to the table height and insensitive to the table width.
Illustratively, the step 102 may include the following steps 102c4 to 102c 6:
step 102c4, in case the table height is larger than the view height, determining a second adjustment ratio depending on how much the table height exceeds the view height.
For example, the second adjustment ratio may be determined according to the degree that the table height exceeds the view height, that is, the more the table height exceeds the view height, the more the number of rows with the row height needs to be adjusted. Wherein the extent to which the table height exceeds the view height may be determined according to the distance by which the table height exceeds the view height, e.g., the greater the distance by which the table height exceeds the view height, the greater the extent to which the table height exceeds the view height is characterized; the determination may also be based on the ratio of the distance that the table height exceeds the view height to the view height, e.g., the greater the ratio of the distance that the table height exceeds the view height to the view height, the greater the degree to which the table height exceeds the view height is characterized.
Step 102c5, determining a third target line in the target area, the line height of which needs to be adjusted, according to the second adjustment proportion; the third target behavior target area is ranked according to the line heights, then the line heights are ranked in the front, and the cells do not contain image content; the number of third target lines is based on a product of the second adjustment ratio and the total number of lines in the target area.
As an example, the row with the top rank higher and no image content in the cell may be b rows with no image content in the cell and the top rank higher, where b is an integer greater than or equal to 1.
And step 102c6, 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.
The third target column is a column to which the cell which adjusts the line height in the target area and sets the text in the cell which cannot be completely displayed after the automatic line feed belongs; and the text in the cell in the adjusted third target column can be completely displayed.
For example, the second preset adjustment scheme may be: and adjusting the line height of the third target line to be a fifth preset proportion of the current line height, and adjusting the column width of the third target column to be a sixth preset proportion of the current column width.
For example, in order to reduce the table 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.
It should be noted that, the step of adjusting the row height first and then adjusting the column width may refer to the description of the step of adjusting the row width first and then adjusting the row height in the step 102c1 to the step 102c3, and therefore, in order to avoid repetition, the description is omitted here.
The method 2 comprises the following steps:
illustratively, the step 102 may include the following steps 102d1 and 102d 2:
step 102d1, when the table width is larger than the view width, adjusting the column width of each column in turn according to the column width in the target area from large to small.
Step 102d2, set the cells in the fourth target row to be auto-wrapping, and adjust the row height of the fourth target row until the table width is less than or equal to the view width.
And the lines to which the cells of which the texts cannot be completely displayed after the column widths are adjusted in the fourth target behavior target area belong.
It can be understood that, in the process of sequentially adjusting the column widths of each column in the order from large to small in the target area, the proportional relationship between the table width and the view width can be calculated in real time, and when the table width is smaller than or equal to the view width, which indicates that all columns of the table can be viewed in the current view, the adjustment of the column widths of the cells in the target area can be stopped.
It should be noted that, the operation step of adjusting the row height of the fourth target row and the operation step of setting the cells in the fourth target row as the automatic row changing do not need to distinguish the order, and the execution results are the same.
Illustratively, the step 102d1 may specifically include: and sequentially adjusting the column width of each column to a seventh preset proportion of the current column width according to the sequence of the column widths from large to small in the target area, setting the cells in the fourth target row to be automatically line-changed and adjusting the row height of the fourth target row to be an eighth preset proportion of the current row height, and stopping adjustment until the table width is smaller than or equal to the view width.
For example, 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.
Specifically, the text in the cell in the adjusted fourth target line can be completely displayed. For example, the product of the seventh predetermined ratio and the eighth predetermined ratio is 1, for example, the seventh predetermined ratio may be one half, the eighth predetermined ratio may be two times, that is, the column width is reduced by half, and the row height is increased by one time. The seventh preset proportion and the eighth preset proportion may be in other relationships as long as the adjusted text in the cells in the fourth target line can be completely displayed.
For example, in the case that the table width is greater than the view width, the columns with larger column widths may be sorted according to the size of the column width of each column in the target area, and the columns with larger column widths are preferentially adjusted until the table width is less than or equal to the view width.
Specifically, for a cell containing only text content, the cell width may be adjusted to be one half of the original width, and the line height may be adjusted to be twice of the original height, so that, under the condition that the cell is set to automatically change lines, the cell content may be ensured to be completely displayed, and the table width may also be reduced.
For example, when the width of the table is greater than the width of the view, the partial cells may be subjected to a folding process, and a column width W _ redundant of the table beyond the view is first calculated as W _ table _ original- (W-15 character), where W _ table _ original is a sum of cell content lengths estimated after the cell content of each column is adjusted to one row, and W is the table view width. Next, each column width of the table is sorted from large to small, and the value at 1/4 bits in the column width is obtained and is marked as 1/4. rank _ w. And (4) turning the sorted columns from large to small according to the column width, wherein the column width of each column is 1/4 & rank _ w, calculating the value of subtracting 1/4 & rank _ w from the column width of each column, and subtracting the value in w _ redundant until the w _ redundant is less than or equal to 0. If the column width of a certain column in 1/4 · rank _ w minus w _ reduce is less than 0, the column width is the column width minus w _ reduce, and the column folding processing is stopped; if 1/4 bits are calculated after sorting, but the column width at the position is still larger than 0 after subtracting w _ reduce, finding a value at 1/2 bits in the sorted column width, marking as 1/2. rank _ w, starting the folding from large to small for each sorted column, the column width of each column is 1/2 rank.w, calculating the value of subtracting 1/2 rank.w from the column width, and subtracting in w _ reduce until w _ reduce is smaller than or equal to 0. And after the width of each column is changed, folding the column, re-estimating the height of the folded column, and setting the alignment mode of the column to be left alignment.
Similarly, referring to the step of adjusting the column width first and then adjusting the row height, the row height may be adjusted first and then the column width may be adjusted under the condition that the user is sensitive to the table height and insensitive to the table width.
Illustratively, the step 102 may further include the following step 102d 2:
and step 102d2, when the table height is greater than the view height, sequentially adjusting the row height of each row according to the sequence of the row heights in the target area from large to small, and adjusting the column width of the fourth target column until the table height is less than or equal to the view height.
The fourth target column is a column to which a cell, of which the text cannot be completely displayed after the line height is adjusted, in the target area belongs; and the text in the cell in the adjusted fourth target column can be completely displayed.
Illustratively, the step 102d2 may specifically include: and sequentially adjusting the ninth preset proportion from the row height of each row to the current row height according to the sequence from the row height in the target area to the row height, adjusting the column width of the fourth target column to the tenth preset proportion of the current column width, and stopping adjustment until the table height is smaller than or equal to the view height.
For example, in order to reduce the table 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.
It should be noted that, for the step of adjusting the row height first and then adjusting the column width, reference may be made to the description of the step of adjusting the column width first and then adjusting the row height in the step 102d1, and details are not described herein again to avoid repetition.
Illustratively, when the table height is greater than the view height, the adjustment can be made as follows. The step 102 may include the following steps 102 e:
and 102e, increasing the line height of each row of cells in the target area according to a preset amplification when the height of the table is larger than the height of the view.
For example, when the table height is greater than the view height, the row height per row in the target area may be increased by 2 pounds. On the basis of typesetting according to a 'moderate' typesetting mode, the height of each row is increased by 2 pounds to increase the space between contents and enable the contents to be displayed more clearly.
According to the table typesetting method provided by the embodiment of the application, the settings of the font, the font size, the font style, the line height, the line width, the alignment mode and the like of the table are automatically adjusted according to the content of the cells in the target area and/or the proportional relation between the table formed by the cells and the view window, so that the operation steps of a user are simplified, and the table sorting efficiency of the user is improved. The method and the device for arranging the table contents comprise a plurality of sets of typesetting modes aiming at the table contents such as fonts, word sizes, line heights, column widths and the like, so that the table arranging effect meets different requirements of users, the visual effect and the readability of the table contents are improved, and the requirement of the users for checking the table contents in various scenes is met.
It should be noted that, in the table layout method provided in the embodiment of the present application, the execution subject may be a table layout device, or a control module in the table layout device for executing the table layout method. The table layout device provided in the embodiment of the present application is described with an example of a table layout device executing a table layout method.
In the embodiments of the present application, the above-described methods are illustrated in the drawings. The table layout method is exemplarily described by referring to one of the drawings in the embodiments of the present application. In specific implementation, the table layout method shown in each method drawing can also be implemented by combining any other drawing which can be combined and is illustrated in the above embodiments, and details are not described here.
The following describes the table layout apparatus provided in the present application, and the table layout methods described below and described above may be referred to correspondingly.
Fig. 3 is a schematic structural diagram of a table layout apparatus according to an embodiment of the present application, and as shown in fig. 3, the schematic structural diagram specifically includes:
an obtaining module 301, configured to obtain a table width and a table height of a table formed by cells in a target area; an adjusting module 302, configured to adjust at least one of a row height and a column width of a cell in the target area according to a proportional relationship between a table width and a view width, and/or a proportional relationship between a table height and a view height; wherein, the view height and the view width are respectively the height and the width of the view window; the view window is for a visual window of the content contained in the cells of the target area.
Optionally, the obtaining module 301 is further configured to obtain target content of the target cell; the target cell is any one of the cells contained in the target area; the adjusting module 302 is further configured to, when the target content is a text content, adjust the target content according to a preset text format, and adjust a format of the target cell according to the adjusted target content; the text content in the adjusted target cell is not rewound and can be completely displayed; or, the adjusting module 302 is further configured to, under the condition that the target content includes the image content, adjust the target content according to a preset image format, and adjust the format of the target cell according to the adjusted target content; and the adjusted image in the target cell can be completely displayed.
Optionally, the adjusting module 302 is specifically configured to adjust a distance between the target content and a border of the target cell according to an area ratio of the area where the target content is located to the area where the target cell is located after adjustment.
Optionally, the obtaining module 301 is further configured to obtain a first target ratio corresponding to any one target column in the table when the width of the table is smaller than the target width; an adjusting module 302, configured to adjust the column width of the target column by taking a product of the first target ratio and the target width as an increase of the target column width; and/or the obtaining module 301 is further configured to obtain a second target ratio corresponding to any target row in the table when the height of the table is smaller than the target height; an adjusting module 302, configured to adjust the line height of the target line by taking the product of the second target ratio and the target height as an increase of the line height of the target line; wherein the target width is a view width of a first preset proportion; the target height is the view height of a second preset proportion; the first target ratio is the ratio of the column width before the target column is adjusted to the table width; the second target ratio is the ratio of the line height before target row adjustment to the table height.
Optionally, the obtaining module 301 is further configured 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 smaller than the view width; an adjusting module 302, configured to adjust the column width of the target column by taking a product of the third target ratio and the view width as an increase of the target column width; and/or the obtaining module 301 is further 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 smaller than the view width; an adjusting module 302, configured to adjust the line height of the target line by taking the product of the fourth target ratio and the view height as an increase of the line height of the target line; wherein the target width is a view width of a first preset proportion; the target height is the view height of a second preset proportion; the third target ratio is the ratio of the column width before the target column is adjusted to the table width; the fourth target ratio is the ratio of the line height before target row adjustment to the table height.
Optionally, the apparatus further comprises: a determining module 303, configured to determine a first adjustment ratio according to a degree that the table width exceeds the view width portion when the table width is greater than the view width; the determining module 303 is further configured to determine, according to the first adjustment ratio, a second target column of the column width to be adjusted in the target area; the second target column is a column which is ranked in front of the column width after being sorted according to the column width in the target area and does not contain image content in the cell; the number of the second target columns is obtained based on the product of the first adjustment proportion and the total number of columns in the target area; an adjusting module 302, configured to adjust a column width of the second target column and a row height of the second target row according to a first preset adjusting scheme; adjusting the column width in the second target behavior target area, and setting the row of the cell which cannot be completely displayed by the text in the cell after automatic line feed; and the text in the cell in the adjusted second target line can be completely displayed.
Optionally, the determining module 303 is configured to determine a second adjustment ratio according to a degree that the table height exceeds the view width when the table height is greater than the view height; the determining module 303 is further configured to determine, according to the second adjustment ratio, a third target row in the target area, where the row height needs to be adjusted; the third target behavior target area is ranked according to the line heights, then the line heights are ranked in the front, and the cells do not contain image content; the number of the third target lines is obtained based on the product of the second adjustment proportion and the total number of lines in the target area; an adjusting module 302, configured to adjust a column width of the third target column and a row height of the third target row according to a second preset adjusting scheme; the third target column is a column to which the cell which adjusts the line height in the target area and sets the text in the cell which cannot be completely displayed after the automatic line feed belongs; and the text in the cell in the adjusted third target column can be completely displayed.
Optionally, the adjusting module 302 is specifically configured to, when the table width is greater than the view width, sequentially adjust the column width of each column according to a sequence from a large column width to a small column width in the target area; setting the cells in the fourth target row as automatic line feed, and adjusting the row height of the fourth target row until the table width is less than or equal to the view width; the lines to which the cells of which the texts cannot be completely displayed after the column widths are adjusted in the fourth target behavior target area belong; and the text in the cell in the adjusted third target column can be completely displayed.
Optionally, the adjusting module 302 is specifically configured to, when the table height is greater than the view height, sequentially adjust a row height of each row according to a sequence from a large row height to a small row height in the target area, and adjust a column width of the fourth target column until the table height is less than or equal to the view height, and stop the adjustment; the fourth target column is a column to which a cell, of which the text cannot be completely displayed after the line height is adjusted, in the target area belongs; and the text in the cell in the adjusted fourth target column can be completely displayed.
According to the table typesetting device, the settings of the fonts, the word sizes, the font styles, the line heights, the line widths, the alignment modes and the like of the tables are automatically adjusted according to the contents of the cells in the target area and/or the proportional relation between the tables formed by the cells and the view window, so that the operation steps of a user are simplified, and the table sorting efficiency of the user is improved. Through the investigation and analysis of the form under each scene by the designer, the setting of the content such as the font, the font size, the line height, the line width and the like under 4 sets of typesetting modes is summarized, so that the form arrangement effect meets different requirements of users, the visual effect and the readability of the form content are improved, and the requirement of the users for checking the form content under various scenes is met.
Fig. 4 illustrates a physical structure diagram of an electronic device, which may include, as shown in fig. 4: a processor (processor)410, a communication Interface 420, a memory (memory)430 and a communication bus 440, wherein the processor 410, the communication Interface 420 and the memory 430 are communicated with each other via the communication bus 440. The processor 410 may call logic instructions in the memory 430 to perform a table layout method comprising: acquiring the table width and the table height of a table formed by the cells in the target area; adjusting at least one of the row height and the column width of the cells in the target area according to the proportional relation between the table width and the view width and the proportional relation between the table height and the view height; wherein, the view height and the view width are respectively the height and the width of the view window; the view window is used for showing a visual window of the content contained in the cells of the target area.
In addition, the logic instructions in the memory 430 may be implemented in the form of software functional units and stored in a computer readable storage medium when the software functional units are sold or used as independent products. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, the present application also provides a computer program product, the computer program product includes a computer program stored on a computer-readable storage medium, the computer program includes program instructions, when the program instructions are executed by a computer, the computer can execute the table layout method provided by the above methods, the method includes: acquiring the table width and the table height of a table formed by the cells in the target area; adjusting at least one of the row height and the column width of the cells in the target area according to the proportional relation between the table width and the view width and the proportional relation between the table height and the view height; wherein, the view height and the view width are respectively the height and the width of the view window; the view window is used for showing a visual window of the content contained in the cells of the target area.
In yet another aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, the computer program being implemented by a processor to perform the table layout method provided above, the method including: acquiring the table width and the table height of a table formed by the cells in the target area; adjusting at least one of the row height and the column width of the cells in the target area according to the proportional relation between the table width and the view width and the proportional relation between the table height and the view height; wherein, the view height and the view width are respectively the height and the width of the view window; the view window is used for showing a visual window of the content contained in the cells of the target area.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods of the various embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.