Custom table generation method and device for printing

By using a table generation method that iterates through each row to determine the top, middle, and bottom strings, the problem of table width not being able to be adjusted adaptively in existing technologies is solved, and consistency between print preview and actual results is achieved.

CN121578960APending Publication Date: 2026-02-27航天银山电气有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511558817.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-29
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

Existing table generation methods cannot adaptively adjust the width, resulting in inconsistencies between print preview and actual results. Furthermore, they cannot merge cells, failing to meet diverse table display needs.

Method used

By traversing the table row by row, the top, middle, and bottom strings of each row are determined. Based on these strings, a preview table is generated, enabling dynamic adjustment of the table content and adaptive width, ensuring that the print preview matches the actual result.

Benefits of technology

It achieves adaptive table adjustment, solves the problem of inconsistency between print preview and actual result, and ensures that the printed result is consistent with the preview effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121578960A_ABST
    Figure CN121578960A_ABST
Patent Text Reader

Abstract

The invention provides a user-defined table generation method and device for printing. The method comprises the steps of determining top left side boundary characters, determining the number of tenth characters based on the top width, determining top right side boundary characters, and determining middle left side characters and middle right side characters; serializing the top left side boundary character, the tenth characters and the top right side boundary character of each row cell into a top character string, and serializing the middle left side character, the cell content and the middle right side character of each row cell into a middle character string; determining a bottom character string of the target line; and generating a preview table of the target table based on the top character string, the middle character string and the bottom character string. According to the technical scheme of the embodiment of the invention, each row of the table can be split into the top, the middle and the bottom for serialization during constant value printing, the table cells are adaptively adjusted according to the filling content, the problem of misalignment of the table is solved, and the printing result and the preview result of the preview table are consistent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of automated printing technology, and in particular to a method and apparatus for generating custom forms for printing. Background Technology

[0002] Fixed-value printing is the operation of outputting pre-set fixed parameters from equipment or systems as fixed values ​​in paper or electronic document form. It is commonly used in industrial control, power protection, and the debugging and routine maintenance of electrical equipment. Generating a table is a crucial step in fixed-value printing. Existing tables typically have fixed rows and columns, making it impossible to merge cells during use, unsuitable for diverse table display needs, and requiring column widths to be set before use; they do not automatically adjust width based on table content. Furthermore, inconsistencies exist between print previews and actual print results across different platforms, and previews may not align correctly. Summary of the Invention

[0003] This invention aims to at least solve one of the technical problems existing in the prior art. To this end, this invention proposes a method and apparatus for generating custom tables for printing, which can serialize tables for fixed-value printing, dynamically adjust the table width according to the table content, and ensure the alignment effect in the print preview.

[0004] In a first aspect, embodiments of the present invention provide a method for generating a custom table for printing, comprising: The target table is traversed row by row from top to bottom, and the currently traversed row is determined as the target row, wherein the target row includes multiple row cells; Based on any of the row cells, determine the top left boundary character, determine the top width of the row cell, determine the number of tenth characters based on the top width, determine the top right boundary character, determine the middle left character and the middle right character, wherein the tenth character is used to represent the top or bottom side of the table that is not at the four corners of the cell; The top left boundary character, multiple tenth characters, and top right boundary character of each row cell are serialized into a top string, and the middle left character, cell content, and middle right character of each row cell are serialized into a middle string; Determine the bottom string of the target row, wherein if the target row is not the last row of the target table, the bottom string is empty; or if the target row is the last row of the target table, the bottom string is obtained by serializing the bottom left character, the cell content, and the bottom right character. The row printing information of the target row is constructed based on the top string, the middle string, and the bottom string, and a preview table of the target table is generated based on the row printing information of all the target tables.

[0005] According to some embodiments of the present invention, determining the top left boundary character includes: The currently traversed row cell is determined as the target cell, and the display mode of the target row is determined, wherein the display mode includes single-row mode or multi-row mode. When the target row is the first row of the target table or is in single-row mode, the first character is determined as the top left border character of the target cell in the first column. In the target cells that are not in the first column, the seventh character is determined as the top left border character of the target cell with a left border, and the eleventh character is determined as the top left border character of the target cell without a left border. The first character is used to represent the top left corner of the table, the seventh character is used to represent the right side of the table that is not a left or right border, and the eleventh character is used to represent the left or right side of the table that is not a four-corner of the cell. Alternatively, when the target row is not the first row of the target table or is in a multi-row mode, for the target cell in the first column, the fifth character is determined as the top left boundary character of the target cell with a top border, and the eleventh character is determined as the top left boundary character of the target cell without a top border. For the target cell that is not in the first column, the top left boundary character of the target cell is determined based on the cell above it. The fifth character is used to represent the left side of the table that is not at the top or bottom border, and the cell above it is the cell located in the row above the target cell and in the same column.

[0006] According to some embodiments of the present invention, determining the top left boundary character of the target cell based on the cell above includes: When both the top cell and the target cell have left borders, the ninth character is determined as the top left border character, wherein the ninth character is used to represent the interior of the table that is not bounded by top, bottom, left, or right borders; When the upper cell has no left border and the target cell has a left border, the seventh character is determined as the top left border character; When the upper cell has a left border and the target cell has no left border, the eighth character is determined as the top left border character, wherein the eighth character is used to represent the bottom side of the table that is not a left or right border. When neither the upper cell nor the target cell has a left border, the tenth character is determined as the top left border character.

[0007] According to some embodiments of the present invention, after determining the ninth character as the top left boundary character, the method further includes: Determine the cell preceding the target cell, wherein the preceding cell is the row cell of the target cell in the column preceding the target row; When both the target cell and the preceding cell have top borders, the ninth character remains the top left border character; When the target cell has a top border and the preceding cell does not have a top border, the top left border character is modified to the fifth character; When the target cell has no top border and the preceding cell has a top border, the top left border character is modified to the sixth character, wherein the sixth character is used to represent the right side of the table that is not the top or bottom border; When the target cell has a left border and the preceding cell has no top border, modify the top left border character to the eleventh character; When the target cell has no left border and the preceding cell has no top border, the top left border character is modified to empty.

[0008] According to some embodiments of the present invention, determining the number of tenth characters based on the top width includes: Based on the target row that is not the first row, if the number of columns in the target row is less than the previous row in the target table, the tenth character corresponding to the end of each column in the previous row is replaced with the eighth character; or, if the number of columns in the target row is greater than the previous row in the target table, the top left boundary character is replaced with the seventh character.

[0009] When the growth attribute of the target table is horizontal growth, for each row cell, if the content width of the cell content is less than or equal to the preset column width, the number of the tenth characters is determined based on the preset column width; or, if the content width is greater than the preset column width, the number of the tenth characters is determined based on the content width. The growth attribute is used to characterize the expansion display direction after the content width exceeds the preset column width. When the growth attribute of the target table is vertical growth, the number of the tenth character is determined according to the preset column width.

[0010] According to some embodiments of the present invention, determining the top right boundary character includes: If the target cell is not located in the last column of the target row, set the top right border character to empty; When the target cell is located in the last column of the target row, and the target row is the first row of the target table or is in single-row mode, the third character is determined as the top right boundary character, wherein the third character is used to represent the upper right corner of the table; When the target cell is located in the last column of the target row, and the target row is not the first row of the target table or is in a multi-row mode, when the target cell has a top border, the sixth character is determined as the top right boundary character; or, when the target cell has no top border, the eleventh character is determined as the top right boundary character.

[0011] According to some embodiments of the present invention, serializing the left-middle character, cell content, and right-middle character of each row cell into an intermediate string includes: When the middle left character and the middle right character are configured to be hidden, the middle left character and the middle right character are set to empty; otherwise, they are set to the eleventh character. Determine the number of characters to fill and the content text of the target cell, and divide the content text into multiple lines of sub-text; When the target cell is in multi-line mode, the cell content is constructed based on the multi-line sequence content, wherein the sequence content includes a fill string, the subtext, the fill string and a newline character in sequence, the last line of the sequence content does not include the newline character, the fill string includes multiple fill characters, and the number of fill characters in each fill string is half the number of fill characters; When the target cell is in single-row mode, the cell content is constructed based on the fill string, the content text, and the fill string.

[0012] According to some embodiments of the present invention, when the target row is located in the last row of the target table, the bottom string is obtained by serializing the bottom left character, the cell content, and the bottom right character, including: The second character is determined as the bottom left character of the first row cell, wherein the second character is used to represent the bottom left corner of the table; Based on any non-first row cell, if the bottom left character is configured to be hidden, the tenth character is determined to be the bottom left character; otherwise, the eighth character is determined to be the bottom left character. The fourth character is determined as the bottom right character of the last row cell, and the bottom right characters of the remaining row cells are set to empty, wherein the fourth character is used to represent the bottom right corner of the table; The bottom width of each row cell is determined based on the number of fill characters.

[0013] According to some embodiments of the present invention, generating a preview table of the target table based on the row printing information of all the target tables includes: Search for multiple optional fonts, wherein the optional fonts include multiple categories of available characters with different language types; When a target font is found, the fill character is set to a space. The width of the space between the fill characters of different types of available characters is determined according to a preset width ratio, wherein the multiple types of available characters of the target font are of equal width. If the target font cannot be found, the padding character is identified as a tab character, and the width of the tab character is set to a unit pixel width. The number of fill characters is determined based on the width of the row cell, the width of the cell content, and the width ratio.

[0014] In a second aspect, embodiments of the present invention provide a custom table generation apparatus for printing, including at least one control processor and a memory for communicatively connecting to the at least one control processor; the memory stores instructions executable by the at least one control processor, the instructions being executed by the at least one control processor to enable the at least one control processor to perform a custom table generation method for printing as described in the first aspect above.

[0015] A custom table generation method for printing according to an embodiment of the present invention has at least the following beneficial effects: Traversing the target table row by row from top to bottom, determining the currently traversed row as the target row, wherein the target row includes multiple row cells; based on any one of the row cells, determining the top left boundary character, determining the top width of the row cell, determining the number of tenth characters based on the top width, determining the top right boundary character, determining the middle left character and the middle right character, wherein the tenth character is used to represent the top or bottom side of the table that is not at the four corners of the cell; and combining the top left boundary character, the multiple tenth characters, and the top right boundary character of each row cell. The boundary characters are serialized into a top string, and the middle left character, cell content, and middle right character of each row cell are serialized into a middle string; the bottom string of the target row is determined, wherein, when the target row is not the last row of the target table, the bottom string is empty, or, when the target row is the last row of the target table, the bottom string is obtained by serializing the bottom left character, cell content, and bottom right character; the row printing information of the target row is constructed based on the top string, the middle string, and the bottom string, and a preview table of the target table is generated based on the row printing information of all the target tables. According to the technical solution of the present invention, each row of the table can be split into top, middle, and bottom for serialization during fixed-value printing, and the cells can be adaptively adjusted according to the filling content to solve the problem of table misalignment, so that the printing result of the preview table is consistent with the preview result. Attached Figure Description

[0016] Figure 1 This is a schematic diagram of a target table provided in one embodiment of the present invention; Figure 2 This is a flowchart of a custom table generation method for printing provided in another embodiment of the present invention; Figure 3 This is a structural diagram of a custom table generation device for printing provided in another embodiment of the present invention. Detailed Implementation

[0017] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0018] In the description of this invention, it should be understood that the orientation descriptions, such as up, down, front, back, left, right, etc., are based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limiting this invention.

[0019] In the description of this invention, "several" means one or more, "more than" means two or more, "greater than," "less than," and "exceeding" are understood to exclude the stated number, while "above," "below," and "within" are understood to include the stated number. The use of "first" and "second" in the description is merely for distinguishing technical features and should not be construed as indicating or implying relative importance, or implicitly indicating the number of indicated technical features, or implicitly indicating the order of the indicated technical features.

[0020] In the description of this invention, unless otherwise explicitly defined, terms such as "set up," "install," and "connect" should be interpreted broadly, and those skilled in the art can reasonably determine the specific meaning of the above terms in this invention in conjunction with the specific content of the technical solution.

[0021] This invention provides a method and apparatus for generating a custom table for printing. The method includes: traversing a target table row by row from top to bottom, determining the currently traversed row as the target row, wherein the target row includes multiple row cells; based on any one of the row cells, determining a top left boundary character, determining the top width of the row cell, determining the number of tenth characters based on the top width, determining a top right boundary character, determining a middle left character and a middle right character, wherein the tenth character is used to represent the top or bottom side of the table, excluding the four corners of the cell; and combining the top left boundary character, the multiple tenth characters, and the... The top right boundary character is serialized into a top string, and the middle left character, cell content, and middle right character of each row cell are serialized into a middle string; the bottom string of the target row is determined, wherein, when the target row is not the last row of the target table, the bottom string is empty, or, when the target row is the last row of the target table, the bottom string is obtained by serializing the bottom left character, cell content, and bottom right character; the row printing information of the target row is constructed based on the top string, middle string, and bottom string, and a preview table of the target table is generated based on the row printing information of all the target tables. According to the technical solution of this embodiment, each row of the table can be split into top, middle, and bottom for serialization during fixed-value printing, and cells can be adaptively adjusted according to the filling content, solving the problem of table misalignment and ensuring that the printed result of the preview table is consistent with the preview result.

[0022] The following is based on the appendix Figure 1 The illustrated table and the table of correspondences for various characters shown in Table 1 further illustrate the technical solution of the embodiments of the present invention.

[0023]

[0024] Table 1: Character Lookup Table Reference Figure 2 , Figure 2 The flowchart illustrates a method for generating a custom table for printing, as provided in an embodiment of the present invention. This method includes, but is not limited to, the following steps: S11 traverses the target table row by row from top to bottom, and determines the currently traversed row as the target row, where the target row includes multiple rows of cells.

[0025] It should be noted that after obtaining the target table, this embodiment traverses the target table row by row, and each row is determined as the target row to execute step S12. In the field of fixed value printing, each row of the table includes at least two rows of cells.

[0026] S12, based on any row cell, determine the top left boundary character, determine the top width of the row cell, determine the number of tenth characters based on the top width, determine the top right boundary character, determine the middle left character and the middle right character, where the tenth character is used to represent the top or bottom edge of the table that is not at the four corners of the cell.

[0027] It should be noted that, as Figure 1 As shown, in this embodiment, each row is broken down into a top string, a middle string, and a bottom string. In actual use, each table can set the top, bottom, left, and right borders of the cells to show or hide them. By hiding the borders, the cells of multiple rows or columns can be merged and displayed. In this embodiment, in step S12, the corresponding characters of each row cell are determined one by one. Finally, the strings of each row cell are serialized to obtain the string corresponding to the entire row.

[0028] It should be noted that the top left margin character is used to represent the left boundary of the row cell. For example, it can be the first, second, fifth, or eleventh character as shown in Table 1, depending on the position of the row cell and the display / hide attribute of the surrounding cells. The top right margin character is similar, and can be the third, fourth, sixth, or eleventh character as shown in Table 1.

[0029] It should be noted that, as shown in Table 1, the tenth character is "─", and therefore can be used as the top border. In this embodiment, the top width is determined based on the cell content of the row cell, and the number of characters in the cell content corresponds to the number of the tenth character, thereby realizing that the width of the row cell is dynamically adjusted according to the content.

[0030] It should be noted that, as Figure 1 As shown, the left-middle character, cell content, and right-middle character of each row cell are used to determine the middle string. Since the width of the top string is determined based on the cell content, it can be ensured that the middle string and the top string can be aligned. The left-middle character and the right-middle character are also determined based on the position of the row cell and the display / hide attribute of the surrounding cells. No further restrictions are made here. For example, they can be the fifth character, the eleventh character, etc. in Table 1.

[0031] S13 serializes the top left boundary character, multiple tenth characters, and top right boundary character of each row cell into a top string, and serializes the middle left character, cell content, and middle right character of each row cell into a middle string.

[0032] It should be noted that after obtaining the top left boundary character, multiple tenth characters, and top right boundary character of each row cell according to step S12, the top characters are serialized in sequence to obtain the top string, and the corresponding middle string is obtained similarly. Through the above operations, the top and middle of the target row can be represented in the form of strings, and it can be ensured that the printed content is aligned.

[0033] S14, determine the bottom string of the target row, where the bottom string is empty if the target row is not the last row of the target table, or the bottom string is obtained by serializing the bottom left character, cell content and bottom right character if the target row is the last row of the target table.

[0034] It should be noted that, since the top string of the next line overlaps with the bottom string of the previous line, in this embodiment only the bottom string of the last line includes the corresponding bottom left character, cell content, and bottom right character, while the bottom strings of other lines are set to empty.

[0035] S15: Construct the row printing information of the target row based on the top string, middle string and bottom string, and generate a preview table of the target table based on the row printing information of the entire target table.

[0036] It should be noted that in this embodiment, the top string, middle string, and bottom string are stored in a cache as row printing information. The target row is printed using this row printing information, and multiple rows of printing information together form the printing information for the target table. During printing, the top string is printed first, completing the top printing of a row; then the middle string is printed, completing the middle printing of a row; and finally, the bottom string of the last row is printed, completing the printing of the target table. During previewing, a preview table is generated row by row based on the row printing information, ensuring that the preview and printed content and format are identical.

[0037] In another embodiment, in step S12, determining the top left boundary character specifically includes, but is not limited to, the following steps: S21: Determine the target cell as the currently traversed row cell, and determine the display mode of the target row. The display mode can be either single-row mode or multi-row mode. S22, when the target row is the first row of the target table or is in single-row mode, the first character is determined as the top left border character of the target cell in the first column. In the target cells that are not in the first column, the seventh character is determined as the top left border character of the target cell with a left border, and the eleventh character is determined as the top left border character of the target cell without a left border. The first character is used to represent the top left corner of the table, the seventh character is used to represent the right side of the table that is not a left or right border, and the eleventh character is used to represent the left or right side of the table that is not a four-corner of the cell. S23, when the target row is not the first row of the target table or is in multi-row mode, for the target cell in the first column, the fifth character is determined as the top left boundary character of the target cell with a top border, and the eleventh character is determined as the top left boundary character of the target cell without a top border. For the target cell that is not in the first column, the top left boundary character of the target cell is determined based on the cell above it. Here, the fifth character is used to represent the left side of the table that is not the top or bottom boundary, and the cell above it is the cell located in the row above the target cell and in the same column.

[0038] It should be noted that, for ease of explanation of the technical solution, this embodiment determines the currently traversed row cell as the target cell. This embodiment serializes the top string and determines the top left boundary character based on its positional relationship with surrounding cells and the display mode. The display modes in this embodiment include single-line mode and multi-line mode. Single-line mode displays a single line of content within the cell, while multi-line mode displays multiple lines of content.

[0039] It should be noted that in step S22, the target row is either the first row or a single row of the table. When the target cell is the first column, it is located at the top left corner of the target table, and the top left border character is the first character shown in Table 1. When the target cell is not the first column, it is necessary to determine whether the target cell has a left border. If there is no left border (e.g., the left border is set to hidden), the seventh character shown in Table 1 is determined as the top left border character. If there is a left border, the eleventh character is used as the top left border character.

[0040] It should be noted that if the target row is not the first row or in single-row mode, the cell above the target cell, or the cell above it, needs to be merged with the cell above it by hiding the top border. In step S23, when the target cell is in the first column and has a top border, the fifth character shown in Table 1 is used as the top left border character; when there is no top border, the eleventh character is used as the top left border character. When the target cell is not in the first column, this target cell has neither horizontal nor vertical borders and is not printed in a single row. The top left border character of the target cell is determined by judging whether the cell above it and the target cell have left borders.

[0041] In another embodiment, in step S23, the top left boundary character of the target cell is determined based on the cell above, which specifically includes, but is not limited to, the following steps: S231, When both the upper cell and the target cell have left borders, the ninth character is determined as the top left border character, where the ninth character is used to represent the interior of the table that is not bounded by the top, bottom, left, or right borders; S232, when the cell above has no left border and the target cell has a left border, the seventh character is determined as the top left border character; S233, when the cell above has a left border and the target cell does not have a left border, the eighth character is determined as the top left border character, where the eighth character is used to represent the bottom of the table that is not a left or right border; S234, when neither the cell above nor the target cell has a left border, the tenth character is determined as the top left border character.

[0042] It should be noted that in step S23, when the target cell is not located in the first column, a comprehensive judgment needs to be made based on the cells above it. In step S231, when both the target cell and the cell above it have left borders, the ninth character shown in Table 1 is used as the top left border character. The ninth character indicates that the target cell is located inside the table and is not at the top, bottom, left, or right borders. The ninth character provides borders for both the target cell and the cell above it.

[0043] In step S232, when the upper cell has no left border and the target cell has a left border, the upper cell is merged with its adjacent row cells. At this time, the seventh character is used as the top left border character of the target cell to represent the top of the table.

[0044] In step S233, when the upper cell has a left border and the target cell does not have a left border, the target cell needs to be merged with the left cell. Therefore, the eighth character is used to provide a left border for the upper cell.

[0045] In step S234, if neither the upper cell nor the target cell has a left border, they are merged, and the tenth character is used as the top left border character.

[0046] In another embodiment, after step S231 is performed, the following steps are included, but are not limited to: S2311, Determine the cell preceding the target cell, where the preceding cell is the row cell of the target cell in the column preceding the target row; S2312, when both the target cell and the preceding cell have top borders, maintain the ninth character as the top left border character; S2313, When the target cell has a top border and the preceding cell does not have a top border, change the top left border character to the fifth character; S2314, When the target cell has no top border and the preceding cell has a top border, change the top left border character to the sixth character, where the sixth character is used to represent the right side of the table that is not the top or bottom border; S2315, When the target cell has a left border and the preceding cell has no top border, change the top left border character to the eleventh character; S2316: When the target cell has no left border and the preceding cell has no top border, change the top left border character to empty.

[0047] It should be noted that in step S231, when it is determined that the top left boundary character is the ninth character, only the case of the two cells above and below is considered. However, in step S231, the target cell is not located in the first column, so it is also necessary to determine whether the top table line is hidden between the target cell and the cell in front of the previous column.

[0048] In step S2312, when both the target cell and the preceding cell have top borders, the ninth character is maintained as the top left border character; In step S2313, if the target cell has a top border and the preceding cell does not, then the table line of the preceding cell is hidden. The ninth character needs to be changed to the fifth character to avoid forming a top border in the preceding cell.

[0049] In step S2314, when the target cell has no top border and the preceding cell has a top border, the top table line of the target cell is hidden, and the top left border character is changed to the sixth character.

[0050] In step S2315, when the target cell has a left border and the preceding cell has no top border, the table line of the preceding cell is hidden, and the top left border character is modified to the eleventh character.

[0051] In step S2316, when the target cell has no left border and the preceding cell has no top border, both cells hide the table lines, and the top left border character is changed to empty, so that the top left border character is not printed.

[0052] In another embodiment, in step S12, the number of tenth characters is determined based on the top width, which specifically includes, but is not limited to, the following steps: S31, based on the target row that is not the first row, if the number of columns in the target row is less than the previous row in the target table, replace the tenth character at the end of each column in the previous row with the eighth character; or, if the number of columns in the target row is greater than the previous row in the target table, replace the top left boundary character with the seventh character.

[0053] S32, when the growth attribute of the target table is horizontal growth, for each row cell, when the content width of the cell content is less than or equal to the preset column width, the number of tenth characters is determined according to the preset column width, or when the content width is greater than the preset column width, the number of tenth characters is determined based on the content width. Here, the growth attribute is used to characterize the expansion display direction after the content width exceeds the preset column width. S33, when the target table's growth attribute is vertical growth, determine the number of tenth characters based on the preset column width.

[0054] It should be noted that, referring to Figure 1 As shown, when the target row is not the first row, it's necessary to determine the top character to match the bottom character at the boundary of the previous cell. If the number of columns in the target row is the same as the previous row, no operations are needed in the middle string; the current top string can be maintained. If the number of columns in the target row is less than the previous row, the tenth character at the end of each column in the previous row is replaced with the eighth character, thus forming a border in the previous row using the upper part of the eighth character. If the number of columns in the target row is greater than the previous row, the top left boundary character is replaced with the seventh character, thus forming a new column border in the target cell.

[0055] It should be noted that when calculating the column width, the number of tenth characters to fill is determined based on the top width. The principle is explained using the preset column width of m as an example and the content width of the cell content as n.

[0056] When the target table's growth attribute is horizontal (meaning the column width increases horizontally when cell content exceeds the default column width), if n ≤ m, the column width will not increase after filling with content. The default column width is usually determined by the number of characters; for example, if the column width is 10 characters, m can be used as the number of the tenth character to create a target cell with a standard width. If n > m, the default list cannot satisfy the content filling requirement. In this case, n is used to determine the number of the tenth character, ensuring the target cell can display its content horizontally, achieving adaptive adjustment of the cell width.

[0057] It should be noted that vertical growth refers to vertical growth (i.e., increasing the row height to add a row to be displayed). In this case, there is no need to consider the display of cell content from a horizontal perspective; the number of tenth cells can be determined based on the preset column width.

[0058] In another embodiment, in step S12, determining the top right boundary character specifically includes, but is not limited to, the following steps: S41, when the target cell is not located in the last column of the target row, set the top right margin character to empty; S42, when the target cell is located in the last column of the target row, and the target row is the first row of the target table or is in single-row mode, the third character is determined as the top right boundary character, where the third character is used to represent the top right corner of the table; S43, when the target cell is located in the last column of the target row, and the target row is not the first row of the target table or is in multi-row mode, when the target cell has a top border, the sixth character is determined as the top right border character, or when the target cell has no top border, the eleventh character is determined as the top right border character.

[0059] It should be noted that when determining the character to the right of the top boundary, first determine whether it is the right boundary through step S41. The right boundary is the last column of the target row. If the target cell is not the last column, the character to the right of the top boundary can be left blank.

[0060] When the target cell is in the last column, it's necessary to distinguish whether it's in single-row or first-row mode. In step S42, if the target cell is in the top right corner of the first row or single-row mode, the third character shown in Table 1 is used as the top right border character. In step S43, if the target cell is not in the first row or single-row mode and has a top border, the sixth character is determined as the top right border character, and the horizontal part of the sixth character is used as the top border. If there is no top border, the eleventh character is used.

[0061] In another embodiment, in step S13, the left-hand middle character, cell content, and right-hand middle character of each row cell are serialized into an intermediate string, which specifically includes, but is not limited to, the following steps: S51, when the middle left character and the middle right character are configured to be hidden, set the middle left character and the middle right character to empty; otherwise, set them to the eleventh character. S52, determine the number of characters to fill and the content text of the target cell, and divide the content text into multiple lines of sub-text; S53, when the target cell is in multi-line mode, construct the cell content based on the multi-line sequence content, wherein the sequence content includes fill string, subtext, fill string and newline character in sequence, the last line sequence content does not include newline character, the fill string includes multiple fill characters, and the number of fill characters in each fill string is half the number of fill characters; S54, when the target cell is in single-row mode, construct the cell content based on the fill string, the content text, and the fill string.

[0062] It should be noted that when serializing the intermediate string, the characters on the left and right sides need to be judged first, and then the cell content is assembled. In step S51, when the characters on the left and right sides of the middle string are configured to be hidden, they are each set to empty. Those not configured to be hidden are used with the eleventh character. For example, if the characters on the left side of the middle string are not hidden and the characters on the right side of the middle string are hidden, then the eleventh character is used, and the characters on the right side of the middle string are set to empty.

[0063] It should be noted that cell content can be displayed in multiple lines, depending on whether it is single-line or multi-line mode. The fill character can be a space. Therefore, the number of fill characters can represent the length. Taking the number of fill characters as t, the column width as m, and the width of the content text as r, then t=mr.

[0064] When the target cell is in multi-line mode, the cell content sequence is t / 2*L+first line sub-text+t / 2*L+'\n'+t / 2*L+second line sub-text+t / 2*L+…, where '\n' is a newline character.

[0065] When the target cell is in single-row mode, the cell content sequence is: t / 2*L + content text + t / 2*L.

[0066] In another embodiment, in step S14, when the target row is located in the last row of the target table, the bottom string is obtained by serializing the bottom left character, cell content, and bottom right character, specifically including but not limited to the following steps: S61, the second character is determined as the bottom left character of the first row cell, where the second character is used to represent the bottom left corner of the table; S62, based on any non-first row cell, if the bottom left character is configured to be hidden, determine the tenth character as the bottom left character; otherwise, determine the eighth character as the bottom left character. S63, the fourth character is determined as the bottom right character of the last row cell, and the bottom right characters of the remaining row cells are set to empty, where the fourth character is used to represent the bottom right corner of the table; S64 determines the bottom width of each row cell based on the number of fill characters.

[0067] It should be noted that the bottom string is only generated at the bottom of the table. When the target row is the last row, the characters on the left and right sides need to be determined. The first row cell in the first column is the bottom left corner of the table, and the bottom left character is the second character shown in Table 1. For rows that are not in the first column, if the bottom left character is set to hidden, the tenth character is used as the bottom right character to avoid the appearance of the left character; otherwise, the eighth character is used, and the character above the eighth character is used as the left character.

[0068] It should be noted that when determining the bottom right character, you only need to set the last row cell to the fourth character to form the right boundary, and leave the rest empty.

[0069] In another embodiment, in step S15, a preview table of the target table is generated based on the row printing information of all target tables, which specifically includes, but is not limited to, the following steps: S71, search for multiple optional fonts, where the optional fonts include multiple classes of available characters with different language types; S72, when the target font is found, the padding character is set to a space, and the width of the space between the padding characters of different types of available characters is determined according to the preset width ratio, wherein the multiple types of available characters of the target font are of equal width; S73, when the target font cannot be found, the padding character is determined to be a tab character, and the width of the tab character is set to a unit pixel width; S74 determines the number of fill characters based on the width of the row cell, the width of the cell content, and the width ratio.

[0070] It should be noted that when previewing the target table, different operating systems have different font libraries. In this embodiment, the system first determines whether to use spaces or tabs as fill characters based on the character font width.

[0071] In this embodiment, when searching for the target font, it is necessary to ensure that the widths of different types of characters are equal. This is because the width of the strings mentioned above in this embodiment is adjusted based on the content, and the number of the top tenth characters is determined by the character width. If the widths of different types of characters are not equal, it can easily affect the display. Therefore, this embodiment uses characters with equal width as the target font, such as Chinese characters, English characters, and special characters (such as Ω) with equal width. If the search finds a font with the default fill character set to a space, the width ratio of single characters to wide characters needs to be configured. For example, for platforms such as Windows, the default width ratio is 1:2, that is, the width of Chinese characters and special characters is twice the width of a space and the width of English characters; for other platforms, the width ratio is 1:p, and the number of fill characters is (cell width – content width) * p, where p is a positive number.

[0072] It should be noted that if no fixed-width font size is found, the padding character will be set to a tab character, and the tab character width will be set to 1 pixel. For other platforms where fixed-width characters cannot be found, let the pixel width of the content text be w, then the number of padding characters will be (cell width – content width) * w.

[0073] like Figure 3 As shown, Figure 3This is a structural diagram of a custom table generation device for printing according to an embodiment of the present invention. The present invention also provides a custom table generation device for printing, comprising: The processor 401 can be implemented using a general-purpose central processing unit (CPU), microprocessor, application specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application. The memory 402 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 402 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 402 and is called and executed by the processor 401 to execute a custom table generation method for printing according to an embodiment of this application. Input / output interface 403 is used to implement information input and output; The communication interface 404 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 405 transmits information between various components of the device (e.g., processor 401, memory 402, input / output interface 403, and communication interface 404); The processor 401, memory 402, input / output interface 403 and communication interface 404 are connected to each other within the device via bus 405.

[0074] This application also provides an electronic device, including a custom table generation device for printing as described above.

[0075] This application embodiment also provides a storage medium, which is a computer-readable storage medium, storing a computer program that, when executed by a processor, implements the above-described method for generating a custom table for printing.

[0076] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof. The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate, and may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0077] It will be understood by those skilled in the art that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically include computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

[0078] The above provides a detailed description of the preferred embodiments of the present invention. However, the present invention is not limited to the above embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention. All such equivalent modifications or substitutions are included within the scope defined by the claims of the present invention.

Claims

1. A method for generating a custom table for printing, characterized in that, include: The target table is traversed row by row from top to bottom, and the currently traversed row is determined as the target row, wherein the target row includes multiple row cells; Based on any of the row cells, determine the top left boundary character, determine the top width of the row cell, determine the number of tenth characters based on the top width, determine the top right boundary character, determine the middle left character and the middle right character, wherein the tenth character is used to represent the top or bottom side of the table that is not at the four corners of the cell; The top left boundary character, multiple tenth characters, and top right boundary character of each row cell are serialized into a top string, and the middle left character, cell content, and middle right character of each row cell are serialized into a middle string; Determine the bottom string of the target row, wherein if the target row is not the last row of the target table, the bottom string is empty; or if the target row is the last row of the target table, the bottom string is obtained by serializing the bottom left character, the cell content, and the bottom right character. The row printing information of the target row is constructed based on the top string, the middle string, and the bottom string, and a preview table of the target table is generated based on the row printing information of all the target tables.

2. The method for generating a custom table for printing according to claim 1, characterized in that, Determine the top left boundary character, including: The currently traversed row cell is determined as the target cell, and the display mode of the target row is determined, wherein the display mode includes single-row mode or multi-row mode. When the target row is the first row of the target table or is in single-row mode, the first character is determined as the top left border character of the target cell in the first column. In the target cells that are not in the first column, the seventh character is determined as the top left border character of the target cell with a left border, and the eleventh character is determined as the top left border character of the target cell without a left border. The first character is used to represent the top left corner of the table, the seventh character is used to represent the right side of the table that is not a left or right border, and the eleventh character is used to represent the left or right side of the table that is not a four-corner of the cell. Alternatively, when the target row is not the first row of the target table or is in a multi-row mode, for the target cell in the first column, the fifth character is determined as the top left boundary character of the target cell with a top border, and the eleventh character is determined as the top left boundary character of the target cell without a top border. For the target cell that is not in the first column, the top left boundary character of the target cell is determined based on the cell above it. The fifth character is used to represent the left side of the table that is not at the top or bottom border, and the cell above it is the cell located in the row above the target cell and in the same column.

3. The method for generating a custom table for printing according to claim 2, characterized in that, The top left boundary character of the target cell is determined based on the cell above, including: When both the top cell and the target cell have left borders, the ninth character is determined as the top left border character, wherein the ninth character is used to represent the interior of the table that is not bounded by top, bottom, left, or right borders; When the upper cell has no left border and the target cell has a left border, the seventh character is determined as the top left border character; When the upper cell has a left border and the target cell has no left border, the eighth character is determined as the top left border character, wherein the eighth character is used to represent the bottom side of the table that is not a left or right border. When neither the upper cell nor the target cell has a left border, the tenth character is determined as the top left border character.

4. A method for generating a custom table for printing according to claim 3, characterized in that, After determining the ninth character as the top left boundary character, the method further includes: Determine the cell preceding the target cell, wherein the preceding cell is the row cell of the target cell in the column preceding the target row; When both the target cell and the preceding cell have top borders, the ninth character remains the top left border character; When the target cell has a top border and the preceding cell does not have a top border, the top left border character is modified to the fifth character; When the target cell has no top border and the preceding cell has a top border, the top left border character is modified to the sixth character, wherein the sixth character is used to represent the right side of the table that is not the top or bottom border; When the target cell has a left border and the preceding cell has no top border, modify the top left border character to the eleventh character; When the target cell has no left border and the preceding cell has no top border, the top left border character is modified to empty.

5. A method for generating a custom table for printing according to claim 4, characterized in that, Determining the number of tenth characters based on the top width includes: Based on the target row that is not the first row, if the number of columns in the target row is less than the previous row in the target table, the tenth character corresponding to the end of each column in the previous row is replaced with the eighth character; or, if the number of columns in the target row is greater than the previous row in the target table, the top left boundary character is replaced with the seventh character. When the growth attribute of the target table is horizontal growth, for each row cell, if the content width of the cell content is less than or equal to the preset column width, the number of the tenth characters is determined based on the preset column width; or, if the content width is greater than the preset column width, the number of the tenth characters is determined based on the content width. The growth attribute is used to characterize the expansion display direction after the content width exceeds the preset column width. When the growth attribute of the target table is vertical growth, the number of the tenth character is determined according to the preset column width.

6. A method for generating a custom table for printing according to claim 4, characterized in that, Determining the top right boundary character includes: If the target cell is not located in the last column of the target row, set the top right border character to empty; When the target cell is located in the last column of the target row, and the target row is the first row of the target table or is in single-row mode, the third character is determined as the top right boundary character, wherein the third character is used to represent the upper right corner of the table; When the target cell is located in the last column of the target row, and the target row is not the first row of the target table or is in a multi-row mode, when the target cell has a top border, the sixth character is determined as the top right boundary character; or, when the target cell has no top border, the eleventh character is determined as the top right boundary character.

7. A method for generating a custom table for printing according to claim 3, characterized in that, The left-hand middle character, cell content, and right-hand middle character of each row cell are serialized into an intermediate string, including: When the middle left character and the middle right character are configured to be hidden, the middle left character and the middle right character are set to empty; otherwise, they are set to the eleventh character. Determine the number of characters to fill and the content text of the target cell, and divide the content text into multiple lines of sub-text; When the target cell is in multi-line mode, the cell content is constructed based on the multi-line sequence content, wherein the sequence content includes a fill string, the subtext, the fill string and a newline character in sequence, the last line of the sequence content does not include the newline character, the fill string includes multiple fill characters, and the number of fill characters in each fill string is half the number of fill characters; When the target cell is in single-row mode, the cell content is constructed based on the fill string, the content text, and the fill string.

8. A method for generating a custom table for printing according to claim 7, characterized in that, When the target row is located in the last row of the target table, the bottom string is obtained by serializing the bottom left character, the cell content, and the bottom right character, including: The second character is determined as the bottom left character of the first row cell, wherein the second character is used to represent the bottom left corner of the table; Based on any non-first row cell, if the bottom left character is configured to be hidden, the tenth character is determined to be the bottom left character; otherwise, the eighth character is determined to be the bottom left character. The fourth character is determined as the bottom right character of the last row cell, and the bottom right characters of the remaining row cells are set to empty, wherein the fourth character is used to represent the bottom right corner of the table; The bottom width of each row cell is determined based on the number of fill characters.

9. A method for generating a custom table for printing according to claim 7, characterized in that, A preview table of the target table is generated based on the row print information of all the target tables, including: Search for multiple optional fonts, wherein the optional fonts include multiple categories of available characters with different language types; When a target font is found, the fill character is set to a space. The width of the space between the fill characters of different types of available characters is determined according to a preset width ratio, wherein the multiple types of available characters of the target font are of equal width. If the target font cannot be found, the padding character is identified as a tab character, and the width of the tab character is set to a unit pixel width. The number of fill characters is determined based on the width of the row cell, the width of the cell content, and the width ratio.

10. A custom table generation device for printing, characterized in that, It includes at least one control processor and a memory for communicatively connecting to the at least one control processor; the memory stores instructions executable by the at least one control processor, which, when executed by the at least one control processor, enable the at least one control processor to perform a custom table generation method for printing as described in any one of claims 1 to 9.