A method, system, device and medium for automatic typesetting of an EXCEL wiring diagram
The automated EXCEL wiring diagram layout method solves the problem of low efficiency of manual layout, realizes efficient, easy-to-read and beautiful automatic layout of wiring diagrams, and reduces the workload of designers.
Patent Information
- Application Number
- CN202211354391.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-31
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2042-10-31
AI Technical Summary
In the prior art, the layout of EXCEL electrical wiring diagrams mainly relies on manual methods, resulting in high workload, low efficiency, and increased manpower and time costs.
This paper provides an automatic layout method for EXCEL wiring diagrams. The method obtains the area to be laid out, traverses the cable number column from top to bottom, merges cell information, fills in the sequence number and initializes it, adjusts the row height, splits cells across pages, and deletes blank rows to achieve automatic layout of the wiring diagram.
It realizes simple and efficient automatic typesetting of wiring diagrams, reduces the workload of designers, improves work efficiency, and ensures the readability and aesthetics of wiring diagrams.
Smart Images

Figure CN115510840B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electrical engineering technology, and in particular to an automatic typesetting method, system, computer equipment and storage medium for an EXCEL wiring diagram. Background Art
[0002] As an important part of electrical production design, EXCEL electrical wiring diagrams provide the necessary basis for wiring construction in the production department. In addition to completing the content of the wiring diagram, designers also need to typeset the wiring diagram to ensure its readability.
[0003] At present, electrical wiring diagrams are mainly laid out using traditional manual methods, which not only increases the workload of designers, but also makes the layout process cumbersome and inefficient, with high labor and time costs.
[0004] Therefore, there is an urgent need to provide a method for automatically typesetting EXCEL wiring diagrams to avoid tedious and inefficient manual typesetting work, reduce the workload of designers, and effectively improve work efficiency. Summary of the Invention
[0005] The purpose of the present invention is to provide an automatic typesetting method for EXCEL wiring diagrams, which effectively solves the application defects of traditional manual typesetting methods, avoids tedious and inefficient manual typesetting work, reduces the workload of designers, and thus effectively improves work efficiency.
[0006] In order to achieve the above objectives, it is necessary to provide an automatic typesetting method, system, computer device and storage medium for an EXCEL wiring diagram in response to the above technical problems.
[0007] In a first aspect, an embodiment of the present invention provides a method for automatically typesetting an EXCEL wiring diagram, the method comprising the following steps:
[0008] Obtaining an EXCEL wiring diagram to be typeset, and obtaining a region to be typeset based on the EXCEL wiring diagram to be typeset;
[0009] Traverse the cable number column from top to bottom in the area to be typeset, obtain merged cell information of each cable number, and perform a cell merging operation and fill in the serial number in the serial number column according to the merged cell information; the merged cell information includes the merged cell position and the number of merged cells;
[0010] In response to the completion of the serial number column processing, initializing the cells in the area to be typeset according to a preset standard;
[0011] In response to the completion of the initialization setting, adjusting the row height of the row where the cell is located to the target row height according to the data content of each cell in the area to be typeset;
[0012] In response to the completion of the row height adjustment, the number of each page break position row in the area to be typeset is obtained in sequence, and it is determined from top to bottom whether there is a cable number cell that spans pages based on the number of each page break position row. If so, the corresponding cable number cells are split and merged until all cable number cells do not span pages.
[0013] In response to the completion of the cross-page adjustment, it is determined whether the first line of each page is a blank line. If so, the entire line is deleted to obtain a typesetting wiring diagram.
[0014] Furthermore, the step of performing a cell merging operation and filling in serial numbers on the serial number column according to the merged cell information includes:
[0015] According to the position of each merged cell, the corresponding merge starting row number in the sequence number column is obtained, and according to the merge starting row number, the cells corresponding to the number of merged cells in the sequence number column are merged from top to bottom to obtain each sequence number cell;
[0016] Traverse each cell of the cable number column from top to bottom, and fill in the serial number cells corresponding to the cells with data in ascending order.
[0017] Furthermore, the step of initializing the cells in the area to be typeset according to a preset standard includes:
[0018] Initialize the row height of the area to be typeset to the initial row height;
[0019] Initialize the font type, font size, font color and fill format of the cells in the area to be typeset to Songti, initial font size, black and automatic line break fill;
[0020] Based on the cable number column, separation rows are set from top to bottom for adjacent cables in the area to be typed.
[0021] Furthermore, the step of setting separation rows for adjacent cables in the area to be typed from top to bottom based on the cable number column includes:
[0022] Traverse the cells of the cable number column from top to bottom and determine whether each cell is a merged cell;
[0023] If the cell is a merged cell and is the same merged cell as the serial number cell in the corresponding serial number column, the merged cell in the current row is split, and if it is determined that the next row of the current merged cell has no content, the next row is deleted;
[0024] If the cell is a merged cell and is not the same merged cell as the cell in the corresponding serial number column, then when it is determined that the next row of the current merged cell has content, insert a row below the current row;
[0025] If the cell is not a merged cell and has content, determine whether the next row of the current merged cell has content. If so, insert a row below the current row.
[0026] If the cell is not a merged cell and has no content, determine whether the next row of the current merged cell has content. If not, delete the next row.
[0027] Furthermore, the step of adjusting the row height of the cell to a target row height according to the data content of each cell in the area to be typeset includes:
[0028] Traversing the cells to be adjusted in the area to be typeset in the order of rows first and columns later, calculating the relationship between the length of the character string of each cell to be adjusted and the multiple of the column width, determining the multiple of the row height for data display based on the multiple relationship, and determining whether each cell to be adjusted is a merged cell;
[0029] If the cell to be adjusted is a merged cell and is the first cell of the merged cell, then when it is determined that the number of rows corresponding to the merged cell is less than the data display row height multiple, the cell average value of the current merged cell is calculated according to the data display row height multiple, and according to the cell average value and the current cell row height, the row heights of the corresponding rows of all cells in the current merged cell are adjusted to the corresponding target row height;
[0030] If the cell to be adjusted is not a merged cell and the data display row height multiple is greater than the current cell row height, the row height of the row corresponding to the current cell is adjusted to the target row height corresponding to the data display row height multiple.
[0031] Furthermore, the step of adjusting the row heights of all rows corresponding to cells in the current merged cell to the corresponding target row height according to the cell amortization value and the current cell row height includes:
[0032] If the cell amortized value is greater than the current cell row height, the row heights of all corresponding rows of cells in the current merged cell are adjusted to the cell amortized value;
[0033] If the cell amortized value is less than the current cell row height and the cell amortized value is greater than the initial row height, the total row height of the current merged cells is calculated, and when the total row height of the current merged cells is less than the row height corresponding to the data display row height multiple, the row height of the row corresponding to the current cell is kept unchanged, and the row heights of the rows corresponding to the remaining cells in the current merged cell are adjusted to the cell amortized value;
[0034] If the cell amortized value is smaller than the initial row height, the row height of the current merged cell remains unchanged.
[0035] Furthermore, the step of determining whether there are cable number cells that span pages based on the number of rows at each page break position, and if so, splitting and merging the corresponding cable number cells until all cable number cells do not span pages includes:
[0036] If the cable number cell at the current page break position is a merged cell and the number of rows of the first cell of the merged cell is less than the number of rows of the current page break position, then insert blank rows before the merged cell to move the merged cell down until the number of rows of the first cell of the merged cell is equal to the number of rows of the current page break position;
[0037] Get the row number of the next page break position, and determine whether the merged cell currently moving down spans pages based on the row number of the next page break position;
[0038] If the merged cell currently moved down spans pages, the merged cell will be split and merged and the row height will be adjusted in the order of columns first and rows with the number of rows at the next page break position as the dividing line. When it is determined that the adjusted merged cell still spans pages, it will be reset and adjusted until the corresponding number of cables that do not span pages are obtained.
[0039] In a second aspect, an embodiment of the present invention provides an automatic typesetting system for an EXCEL wiring diagram, the system comprising:
[0040] An information acquisition module is used to acquire an EXCEL wiring diagram to be typeset, and obtain an area to be typeset based on the EXCEL wiring diagram to be typeset;
[0041] A serial number filling module is used to traverse the cable number column from top to bottom in the area to be typeset, obtain the merged cell information of each cable number, and perform a cell merging operation and serial number filling on the serial number column according to the merged cell information; the merged cell information includes the merged cell position and the number of merged cells;
[0042] An initial layout module, configured to initialize the cells in the area to be layout according to a preset standard in response to completion of the serial number column processing;
[0043] A row height adjustment module, configured to adjust the row height of the cell to a target row height according to the data content of each cell in the area to be typeset in response to completion of the initialization setting;
[0044] A page span adjustment module is configured to, in response to the completion of the row height adjustment, sequentially obtain the row numbers of each page break position in the area to be typeset, and determine from top to bottom based on the row numbers of each page break position whether there are cable number cells that span pages; if so, split and merge the corresponding cable number cells until all cable number cells do not span pages;
[0045] The page adjustment module, in response to completion of the cross-page adjustment, determines whether the first line of each page is a blank line. If so, the entire line is deleted to obtain a typesetting wiring diagram.
[0046] In a third aspect, an embodiment of the present invention further provides a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0047] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.
[0048] The above-mentioned application provides an automatic typesetting method, system, computer equipment and storage medium for EXCEL wiring diagrams. Through the method, it is realized that the area to be typeset is obtained according to the acquired EXCEL wiring diagram to be typeset, the cable number column is traversed from top to bottom in the area to be typeset to obtain the merged cell information of each cable number, and the serial number column is merged and the serial number is filled in according to the merged cell information. Then, the cells in the area to be typeset are initialized according to the preset standard, and the row height of the row where the cell is located is adjusted to the target row height according to the data content of each cell in the area to be typeset, and according to the number of rows of each page break position in the acquired area to be typeset, it is judged from top to bottom whether there are cable number cells that cross pages. If so, the corresponding cable number cells are split and merged until all cable number cells do not cross pages, and the blank lines at the first row of each page are deleted to realize the technical solution for automatic typesetting of wiring diagrams. Compared with the existing technology, this automatic typesetting method for EXCEL wiring diagrams realizes simple and efficient automatic typesetting of wiring diagrams, which not only ensures that the wiring diagrams meet the application requirements of being easy to read and use, but also effectively avoids tedious and inefficient manual typesetting work, reduces the workload of designers, and improves work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 This is a schematic diagram of an EXCEL wiring diagram to be typeset in an embodiment of the present invention;
[0050] Figure 2 1 is a flow chart of an automatic typesetting method for an EXCEL wiring diagram according to an embodiment of the present invention;
[0051] Figure 3 This is a schematic diagram of the processing effect of the sequence number column in the EXCEL wiring diagram to be typeset in an embodiment of the present invention;
[0052] Figure 4 This is a schematic diagram of the effect of initializing the row height of the area to be typeset in the EXCEL wiring diagram to be typeset in an embodiment of the present invention;
[0053] Figure 5 This is a schematic diagram showing the initialization effect of the font type, font size, font color, and fill format of the EXCEL wiring diagram to be typeset in an embodiment of the present invention;
[0054] Figure 6 This is a schematic diagram showing the effect of adding separator lines between cables in an EXCEL wiring diagram to be typeset in an embodiment of the present invention;
[0055] Figure 7 1. It is a schematic diagram showing the effect of adjusting the row height of an EXCEL wiring diagram to be typeset in an embodiment of the present invention;
[0056] Figure 8 Figures a and b represent schematic diagrams of two merged cells across pages of an EXCEL wiring diagram to be typeset in an embodiment of the present invention;
[0057] Figure 9 a and b represent Figure 8 Schematic diagram of the processing effect of two merged cells across pages;
[0058] Figure 10 This is a schematic diagram of a situation in which a blank line appears at the first line of an EXCEL wiring diagram to be typeset after being adjusted across pages in an embodiment of the present invention;
[0059] Figure 11 This is a schematic diagram showing the effect of automatically typeset an EXCEL wiring diagram in an embodiment of the present invention;
[0060] Figure 12 1 is a schematic diagram of the structure of an automatic typesetting system for an EXCEL wiring diagram according to an embodiment of the present invention;
[0061] Figure 13 1 is a diagram showing the internal structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solutions and beneficial effects of this application more clear, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. Obviously, the embodiments described below are part of the embodiments of the present invention and are only used to illustrate the present invention, but are not used to limit the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0063] The automatic typesetting method of EXCEL wiring diagram provided by the present invention is a computer-aided shipbuilding technology, which can be used to automatically typeset the wiring diagram completed by designers. Figure 1 The wiring diagram shown is automatically typeset so that the wiring diagram meets the application requirements of being easy to read and use. The following embodiment will describe the automatic typesetting method of the EXCEL wiring diagram of the present invention in detail, and the cable in the text is used to represent the wiring content of a cable in the wiring diagram.
[0064] In one embodiment, Figure 2 As shown, a method for automatically typesetting an EXCEL wiring diagram is provided, comprising the following steps:
[0065] S11. Obtain an EXCEL wiring diagram to be typeset, and obtain an area to be typeset based on the EXCEL wiring diagram to be typeset; wherein the area to be typeset can be understood as all cell areas filled with data content in the EXCEL wiring diagram to be typeset, including a serial number column, a cable number column, a cable model and specification column, a starting device column, and a terminal device column.
[0066] S12, traverse the cable number column from top to bottom in the area to be typed, obtain the merged cell information of each cable number, and perform cell merging operation and fill in the serial number of the sequence number column according to the merged cell information; the merged cell information includes the merged cell position and the number of merged cells; wherein the serial number of the sequence number column can be understood as the order of the cables in the wiring diagram, such as Figure 1 As shown, the merged cells in the serial number column (usually set to column "A", but can also be other columns) need to be consistent in number and position with the merged cells in the cable number column on the right (usually set to column "B", but can also be other columns), and the serial number column cells are automatically incremented based on whether there is content in the cable number column cells; specifically, the steps of merging cells in the serial number column and filling in serial numbers based on the merged cell information include:
[0067] According to the position of each merged cell, the corresponding merge starting row number in the sequence number column is obtained, and according to the merge starting row number, the cells corresponding to the number of merged cells in the sequence number column are merged from top to bottom to obtain each sequence number cell;
[0068] Traverse each cell of the cable number column from top to bottom, and fill in the serial number cells corresponding to the cells with data in ascending order;
[0069] The process of merging cells and filling in serial numbers in the above serial number column is as described in the example: Figure 1If the 4th to 6th rows of the Cable Number column are merged cells, then the 4th to 6th rows of the Serial Number column are also set as merged cells; if the 8th to 10th rows of the Cable Number column are merged cells, then the 8th to 10th rows of the Serial Number column are also set as merged cells; from top to bottom, and so on, until the end cell entered by the user. If there is content in the cell in the 4th row of the Cable Number column (where the first cable is located), the content of the cell in the 4th row of the Serial Number column is "1" (depending on the initial value entered by the user); if there is content in the cell in the 8th row of the Cable Number column, the content of the cell in the 8th row of the Serial Number column is "2"; from top to bottom, and so on, until the end cell entered by the user, we get Figure 3 The treatment effects are shown.
[0070] S13. In response to the completion of the serial number column processing, the cells in the area to be typeset are initialized according to a preset standard; wherein the initialization settings include initializing row height, font type, font size, font color, and fill format, etc. Specifically, the step of initializing the cells in the area to be typeset according to the preset standard includes:
[0071] Initialize the row height of the area to be typeset to the initial row height; wherein, the initial row height can be selected according to actual needs in principle. In this embodiment, in order to make the wiring diagram neat and beautiful, Figure 4 As shown, the row height of the area to be typeset in the current wiring diagram is automatically initialized to 15 based on experience.
[0072] The font type, font size, font color and fill format of the cells in the area to be typeset are initialized to Songti, initial font size, black and automatic line break fill in sequence; wherein, the font size can be freely set in principle. In this embodiment, in order to make the length of each cell string a multiple of the column width of this cell, it is convenient to adjust the row height later, such as Figure 5 As shown, the initial font size is preferably set to 11.
[0073] Based on the cable number column, separator rows are set for adjacent cables in the area to be typed from top to bottom; wherein, the separator row can be understood as a blank row that can clearly distinguish each cable. In order to make the wiring diagram neat and beautiful, in this embodiment, preferably, only one blank row is set as a separator between every two cables in the area to be typed of the wiring diagram: if there is no separator between the two cables, a blank row is inserted as a separator; if there is more than one blank row between the two cables, the extra blank rows are deleted, and only one blank row is retained as a separator; specifically, the step of setting separator rows for adjacent cables in the area to be typed from top to bottom based on the cable number column includes:
[0074] Traverse the cells of the cable number column from top to bottom and determine whether each cell is a merged cell;
[0075] If the cell is a merged cell and is the same merged cell as the serial number cell in the corresponding serial number column, the merged cell in the current row is split, and if it is determined that the next row of the current merged cell has no content, the next row is deleted;
[0076] If the cell is a merged cell and is not the same merged cell as the cell in the corresponding serial number column, then when it is determined that the next row of the current merged cell has content, insert a row below the current row;
[0077] If the cell is not a merged cell and has content, determine whether the next row of the current merged cell has content. If so, insert a row below the current row.
[0078] If the cell is not a merged cell and has no content, determine whether the next row of the current merged cell has content. If not, delete the next row.
[0079] The above process of adding separator rows can be understood as follows: 1) Considering that each cable must have a cable number, the cable number column (column B) is used as the basis to process the layout area from top to bottom; 2) If the current cell of the cable number column (column B) is a merged cell, and it is not the same merged cell as the serial number column (column A) (if columns A and B are both merged cells, it is a blank row, but if column B is a merged cell, it means that column B has a cable number and is not a blank row), then determine whether the cells in the wiring diagram range of the next row of the current merged cell have content. If there is content, insert a row (row height is 15); 3) If the cable number column (column B) is the same as the serial number column (column A), If there are merged cells, it is a blank row. In order to make the wiring diagram uniform and beautiful, split the merged cells in this row and determine whether there is content in the cells in the next row of wiring diagram. If there is no content, delete the row; return to step 2) and repeat the operation; 4) If the current cell in the cable number column (column B) is not a merged cell and has content, determine whether the cell below the current cell has content. If there is content, insert a row (row height is 15); 5) If the current cell in the cable number column (column B) is not a merged cell and has no content, determine whether the cell below the current cell has content. If there is no content, delete the row; return to step 2) and repeat the operation. After the above conditional separation row processing, we get Figure 6 The effect shown.
[0080] S14. In response to the completion of the initialization setting, the row height of the row where the cell is located is adjusted to the target row height according to the data content of each cell in the area to be typeset; wherein the target row height can be understood as a row height that ensures that the data content of each cell is displayed completely, and the target row height corresponding to each row is set according to the data content of its corresponding cell and is not necessarily the same; specifically, the step of adjusting the row height of the row where the cell is located to the target row height according to the data content of each cell in the area to be typeset includes:
[0081] Traversing the cells to be adjusted in the area to be typeset in the order of rows first and columns later, calculating the multiple relationship between the string length and the column width of each cell to be adjusted, determining the multiple of the data display row height based on the multiple relationship, and judging whether each cell to be adjusted is a merged cell; wherein, the calculation of the multiple relationship between the string length and the column width is as follows: if the string length is 8 and the column width is 8, then the string length is 1 times the column width; if the string length is 16 and the column width is 8, then the string length is 2 times the column width; and so on, other multiple relationships can be obtained;
[0082] If the cell to be adjusted is a merged cell and is the first cell of the merged cell, then when it is determined that the number of rows corresponding to the merged cell is less than the data display row height multiple, the cell average value of the current merged cell is calculated according to the data display row height multiple, and according to the cell average value and the current cell row height, the row heights of the corresponding rows of all cells in the current merged cell are adjusted to the corresponding target row height; wherein, according to the cell average value and the current cell row height, the step of adjusting the row heights of the corresponding rows of all cells in the current merged cell to the corresponding target row height includes: if the cell average value is greater than the current If the row height of the previous cell is greater than the row height of the previous cell, the row heights of the rows corresponding to all cells in the current merged cell are adjusted to the cell-averaged value; if the cell-averaged value is less than the current cell row height and the cell-averaged value is greater than the initial row height, the total row height of the current merged cell is calculated, and when the total row height of the current merged cell is less than the row height corresponding to the data display row height multiple, the row height of the row corresponding to the current cell is kept unchanged, and the row heights of the rows corresponding to the remaining cells in the current merged cell are adjusted to the cell-averaged value; if the cell-averaged value is less than the initial row height, the row height of the current merged cell is kept unchanged;
[0083] If the cell to be adjusted is not a merged cell and the data display row height multiple is greater than the current cell row height, the row height of the row corresponding to the current cell is adjusted to the target row height corresponding to the data display row height multiple;
[0084] The above-mentioned row height adjustment process can be understood as first calculating the relationship between the length of each cell string and the multiple of the column width to find out the row height multiple required to display the complete data content. For example, the row height required to display the complete data content at 1 times is 1*15, 2 times is 2*15, and n times is n*15; if the string contains the "Enter" special character, then calculate the row height multiple required for each string before the "Enter" and then add them up; if the string does not contain the "Enter" special character, calculate the row height multiple required for the entire string; then process the cells in the typesetting area by first row and then column, Figure 1 For the wiring diagram shown, start from the second cell (the first cell is the serial number, no row height adjustment is required) in the fourth row (the first three rows are table headers, no row height adjustment is required), and process one cell from left to right in sequence until all the used cells in this row are processed. Then go to the second cell in the next row and process from left to right in sequence, and so on, until all the used cells in this table are processed.
[0085] By performing the following specific steps, you can get Figure 7 The results shown are:
[0086] 1) First get the content of the cell currently being processed, and delete the carriage returns and spaces before and after the content (the carriage returns and spaces before and after the content are not standardized and will affect the effect of adjusting the row height);
[0087] 2) Get the column width a2 of the cell currently being processed, and the column width a2 is rounded down;
[0088] 3) If the string contains the "Enter" special character, obtain the length L1 of the string before each "Enter", divide this length L1 by the column width a2, and round up to get the row height multiple L3 required for the string before each "Enter", and then add them together to get a total row height multiple L5;
[0089] 4) In order to avoid repeated adjustments and improve the running speed, when the current cell is a merged cell, only the case of the first cell of the merged cell is considered: Since the merged cells in the cable wiring diagram targeted by the present invention are all in columns, the number of merged cells a is the number of rows occupied by the current cell. If the number of merged cells is less than the row height multiple L5 (if a is greater than or equal to L5, it means that the number of rows occupied by the current cell is greater than or equal to the required total row height multiple, the data content can be fully displayed, and there is no need to adjust the row height), the required row height is evenly distributed to each cell of the merged cell, and the cell average value L4 = 15*L5 / a (here 15 is the initial row height, because the row height adjustment will only be adjusted to be greater than 15, and the row height value will not be less than 1 5, so the required total row height is 15*L5 to meet the requirement of displaying all data content). If the cell amortized value L4 is greater than the row height b of the row where the current cell is located, the row height of all rows where the merged cell is located is adjusted to the cell amortized value L4; if the cell amortized value L4 is less than or equal to the row height b of the row where the current cell is located but greater than the initial row height 15, then it is necessary to calculate the row height of the row where the current cell is located plus the total row height 15*(a-1) of the cells in this merged cell except the current cell, and obtain the total row height b+15*(a-1) of the current merged cell. If it is less than the required row height 15*L5, it is necessary to adjust the row height of the rows where the cells in this merged cell except the current cell are located to the cell amortized value L4. If the cell amortized value L4 is less than or equal to the initial row height 15, no adjustment is required;
[0090] 5) If the current cell is not a merged cell and the total row height L5*15 is greater than the row height of the row where the current cell is located, the row height is adjusted to the required total row height L5*15.
[0091] 6) If the string in the cell does not contain the special character "Enter", obtain the length L1 of the entire string, divide this length L1 by the column width a2, and round up to obtain the row height multiple L3; replace L5 in steps 4) and 5) with L3 and perform the same steps to ensure the complete display of the data content.
[0092] S15. In response to the completion of the row height adjustment, the row numbers of each page break position in the area to be typeset are obtained in sequence, and it is determined from top to bottom whether there are cable number cells that span pages according to the row numbers of each page break position. If so, the corresponding cable number cells are split and merged until all cable number cells do not span pages; wherein, cables span pages only exist in cables whose cable number column (column B) is a merged cell, such as Figure 8As shown in a-8b, the merged cells are distributed across two pages, which is not conducive to reading. This embodiment uses the cable number column (column B) as the judgment basis to process this item: find the row number of each page break. If there is a cable that spans across pages, insert a blank line above the cable that spans across pages to move the first row of the cable down to the first row of the next page. If the cable is too large after moving down and continues to span pages, split the cable and distribute it reasonably on the subsequent pages. After the split and merge operations are performed, re-judge whether the data content of the cell is displayed completely and adjust the row height.
[0093] Specifically, the step of determining whether there are cable number cells that span pages based on the number of rows at each page break position, and if so, splitting and merging the corresponding cable number cells until all cable number cells do not span pages includes:
[0094] If the cable number cell at the current page break position is a merged cell and the number of rows of the first cell of the merged cell is less than the number of rows of the current page break position, then insert blank rows before the merged cell to move the merged cell down until the number of rows of the first cell of the merged cell is equal to the number of rows of the current page break position;
[0095] Get the row number of the next page break position, and determine whether the merged cell currently moving down spans pages based on the row number of the next page break position;
[0096] If the merged cell currently moved down spans pages, the merged cell is split and merged and the row height is adjusted in the order of columns first and rows with the number of rows at the next page break position as the dividing line. If it is determined that the merged cell after adjustment still spans pages, it is reset and adjusted again until the corresponding number of cables that do not span pages are obtained;
[0097] The specific steps are as follows:
[0098] 1) Based on the cable number column (column B), use VBA statements to obtain the number of page breaks q2, and then determine and adjust the position of each page break in turn;
[0099] 2) Considering that the page break in EXCEL is at the first row of the next page, if the page break on page 1 is at the first row of page 2, use VBA statement to find the row number i1 where the next page break is located;
[0100] 3) If the cell in column B of row i1 is a merged cell, and the row number q of the first cell of the merged cell is less than i1, insert a row (row height 15);
[0101] 4) Repeat step 3) until the number of rows q of the first cell of the merged cell is equal to i1.
[0102] 5) Considering that inserting rows in steps 3) and 4) may increase the page number and the number of page breaks, the number of page breaks q2 is retrieved again;
[0103] 6) Determine whether the moved cable can fit on one page: Find the row number i11 where the page break on the next page in step 2) is located. The number of rows on the next page to be moved is hang = i11 - i1. If the number of merged cells currently being processed is greater than the number of rows hang on the next page to be moved, split the cable containing the merged cell currently being processed into two cables and distribute them across two or more pages.
[0104] 7) Process the cables that need to be split in the order of columns first and rows: first obtain the number a of the current merged cells and the distance c between the first row of the current merged cells and the page break position i11, and determine whether the current merged cell spans the page break position i11 (non-merged cells do not span pages). If a>c, the current merged cell spans pages and needs to be split.
[0105] 8) Split the current merged cells. The split cells are merged according to the page break position i11. However, it is necessary to re-judge whether the data content is displayed completely and adjust the row height. The detailed steps include:
[0106] (8.1) Create an array to record the column number, starting cell, and ending cell of each merged cell before splitting, in preparation for resetting;
[0107] (8.2) Get the content of the cell currently being processed;
[0108] (8.3) Get the column width a2 of the cell currently being processed, and the column width a2 is rounded down;
[0109] (8.4) If the string contains the special character "Enter", obtain the length L1 of the string before each "Enter", divide this length L1 by the column width a2, and round up to get the row height multiple L3 required for the string before each "Enter", and then add them together to get a total row height multiple L5;
[0110] (8.5) If the total row height multiple L5 is greater than the distance c between the first row of the current merged cell and the page break position i11, and L5>c, then merge the cells from the first cell after the split to the previous cell at the page break position i11 (that is, the cells above the page break position i11 after the split), and calculate the average row height L4 = L5*15 / c allocated to each cell after the merge. If the allocated value L4 is greater than the row height b of the row where the current cell is located, then adjust the heights of all rows where the merged cell is located to the allocated value L4. If the apportioned value L4 is less than or equal to the row height b of the current cell but greater than the initial row height 15, then you need to calculate the row height b of the current cell plus the total row height of the cells in this merged cell excluding the current cell, 15*(a-1), to get the total row height b+15*(a-1) of the current merged cell. If it is less than the required row height 15*L5, you need to adjust the row height of the cells in the merged cell excluding the current cell to the apportioned value L4; if the apportioned value is less than or equal to the initial row height 15, no adjustment is required;
[0111] (8.6) After adjusting the row height, you need to determine whether the current merged cell spans pages. Get the page break position i111 after adjusting the row height and compare it with i11 before adjusting the row height. If i11>i111, the current merged cell spans pages after adjusting the row height. You need to merge and reset all previously split cells in this cable, and return to step 7 to start the process again until the current merged cell does not span pages after adjusting the row height.
[0112] (8.7) If the total row height multiple L5 of the current cell is less than or equal to the distance c between the first row of the current merged cell and the page break position i11, and L5≤c, then directly merge the cells from the first cell after the split to the cell above the page break position i11 (that is, the cells above the page break position i11 after the split);
[0113] (8.8) If the total row height multiple L5 of the current cell is greater than the number of cells at and below the page break position i11 after the split, merge the cells at and below the page break position i11, adjust the row height, and follow the steps similar to (8.5). Copy the data content to the merged cells (because after the merged cells are split, only the first cell after the split has data content, and the rest of the cells have no content. Therefore, the cells below the spread have no content after the merge, so the data content needs to be copied to them).
[0114] (8.9) If the total row height multiple L5 is less than or equal to the number of cells at page break position i11 and below after the split, merge the cells at page break position i11 and below, and copy the data content to the merged cells;
[0115] (8.10) If the string does not contain the "Enter" special character, obtain the length L1 of the entire string. If the length L1 of the string is greater than the column width a2, the row height needs to be adjusted. Divide this length L1 by the column width a2 and round up to get a row height multiple L3.
[0116] (8.11) The steps are the same as (8.5) to (8.9), except that L5 is changed to L3;
[0117] (8.12) If the string length L1 is less than or equal to the column width a2, there is no need to adjust the row height; merge the upper and lower cells of the page break position i11, and copy the data content to the merged cells below the spread.
[0118] Through the above-mentioned cross-page adjustment steps, all cross-page cells in the wiring diagram can be reasonably adjusted to obtain the following Figure 9 The effect shown in a-9b.
[0119] S16, in response to the completion of the cross-page adjustment, determine whether the first line of each page is a blank line, if so, delete the entire line to obtain the layout wiring diagram; wherein, the first line of each page does not need to be distinguished from the cables on the previous page by alternate lines, but needs to be Figure 10 As shown, the empty rows moved to the first row of the page due to page adjustment are deleted; preferably, in this embodiment, whether the first row of each page is an empty row is determined based on the row where the page break is located: if the cell in column B located in the row of page break i1 is not a merged cell and has no content, it is determined to be an empty row and the entire row is deleted.
[0120] Through the above steps S11-S16, such as serial number column processing, initialization processing, row height adjustment, cross-page adjustment and page first line processing, the automatic layout of the wiring diagram can be completed. Figure 11 Attractive and easy to read wiring diagrams are shown to meet application requirements.
[0121] The embodiment of the present application obtains the area to be typeset based on the acquired EXCEL wiring diagram to be typeset, traverses the cable number column from top to bottom in the area to be typeset to obtain the merged cell information of each cable number, and performs cell merging operations and serial number filling on the serial number column according to the merged cell information, initializes the cells in the area to be typeset according to the preset standard, and adjusts the row height of the row where the cell is located to the target row height according to the data content of each cell in the area to be typeset, and determines from top to bottom whether there are cable number cells that cross pages based on the number of rows of each page break position acquired in the area to be typeset, and if so, splits and merges the corresponding cable number cells until all cable number cells do not cross pages, then deletes the blank rows at the first row of each page to obtain a technical solution for typeset wiring diagrams, realizes automatic, simple and efficient typesetting of wiring diagrams, not only ensures that the wiring diagrams meet the application requirements of being easy to read and use, but also effectively avoids tedious and inefficient manual typesetting work, reduces the workload of designers, and improves work efficiency.
[0122] In one embodiment, Figure 12 As shown, an automatic typesetting system for EXCEL wiring diagrams is provided, the system comprising:
[0123] Information acquisition module 1, used to obtain the EXCEL wiring diagram to be typeset, and obtain the area to be typeset based on the EXCEL wiring diagram to be typeset;
[0124] Serial number filling module 2 is used to traverse the cable number column from top to bottom in the area to be typeset, obtain the merged cell information of each cable number, and perform cell merging operations and serial number filling in the serial number column according to the merged cell information; the merged cell information includes the merged cell position and the number of merged cells;
[0125] Initial layout module 3, configured to initialize the cells in the area to be layout according to a preset standard in response to the completion of the sequence number column processing;
[0126] A row height adjustment module 4 is configured to adjust the row height of each cell in the area to be typeset to a target row height in response to completion of the initialization setting and according to the data content of each cell in the area to be typeset;
[0127] The page span adjustment module 5 is configured to, in response to the completion of the row height adjustment, sequentially obtain the row numbers of each page break position in the area to be typeset, and determine from top to bottom based on the row numbers of each page break position whether there is a cable number cell that spans pages; if so, split and merge the corresponding cable number cells until all cable number cells do not span pages;
[0128] The page adjustment module 6 is used to judge whether the first line of each page is a blank line in response to the completion of the cross-page adjustment. If so, delete the entire line to obtain a typesetting wiring diagram.
[0129] The specific limitations of the automatic typesetting system for Excel wiring diagrams can be found in the aforementioned limitations of the automatic typesetting method for Excel wiring diagrams, and will not be further elaborated here. Each module in the aforementioned automatic typesetting system for Excel wiring diagrams can be implemented in whole or in part via software, hardware, or a combination thereof. Each of these modules can be embedded in or independent of a processor in a computer device in hardware form, or can be stored in a computer device memory in software form, allowing the processor to call and execute the corresponding operations of each module.
[0130] Figure 13 FIG. 1 shows an internal structure diagram of a computer device in one embodiment, which may be a terminal or a server. Figure 13 As shown, the computer device includes a processor, memory, network interface, display and input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, it implements an automatic typesetting method for an EXCEL wiring diagram. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse.
[0131] It can be understood by those skilled in the art that Figure 13 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computing device may include more or fewer components than shown in the figure, or combine certain components, or have the same component arrangement.
[0132] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0133] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are implemented.
[0134] In summary, the embodiment of the present invention provides an automatic typesetting method, system, computer device and storage medium for an EXCEL wiring diagram. The automatic typesetting method for an EXCEL wiring diagram obtains an area to be typeset according to the acquired EXCEL wiring diagram to be typeset, traverses the cable number column from top to bottom in the area to be typeset to obtain the merged cell information of each cable number, and performs a cell merging operation and fills in the serial number on the serial number column according to the merged cell information, initializes the cells in the area to be typeset according to a preset standard, and sets the cell in the row where the cell is located according to the data content of each cell in the area to be typeset. The row height is adjusted to the target row height, and according to the obtained number of rows of each page break position in the area to be typeset, it is determined from top to bottom whether there are cable number cells that cross pages. If so, the corresponding cable number cells are split and merged until all cable number cells do not cross pages, and then the blank lines at the first row of each page are deleted to obtain a technical solution for typeset wiring diagrams. This method uses a computer to realize simple and efficient automatic typeset of wiring diagrams, which not only ensures that the wiring diagrams meet the application requirements of being easy to read and use, but also effectively avoids tedious and inefficient manual typesetting work, reduces the workload of designers, and improves work efficiency.
[0135] Each embodiment in this specification is described in a progressive manner, and the same or similar parts of each embodiment can be directly referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. It should be noted that the various technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the various technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0136] The above-described embodiments merely represent several preferred implementations of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent. It should be noted that a person skilled in the art could make several improvements and substitutions without departing from the technical principles of the present invention, and these improvements and substitutions should also be considered within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be based on the scope of protection of the claims.
Claims
1. An automatic typesetting method for an EXCEL wiring diagram, characterized in that: The method comprises the following steps: Obtaining an EXCEL wiring diagram to be typeset, and obtaining a region to be typeset based on the EXCEL wiring diagram to be typeset; Traverse the cable number column from top to bottom in the area to be typeset, obtain merged cell information of each cable number, and perform a cell merging operation and fill in the serial number in the serial number column according to the merged cell information; the merged cell information includes the merged cell position and the number of merged cells; In response to the completion of the serial number column processing, initializing the cells in the area to be typeset according to a preset standard; In response to the completion of the initialization setting, adjusting the row height of the row where the cell is located to the target row height according to the data content of each cell in the area to be typeset; In response to the completion of the row height adjustment, the number of each page break position row in the area to be typeset is obtained in sequence, and it is determined from top to bottom whether there is a cable number cell that spans pages based on the number of each page break position row. If so, the corresponding cable number cells are split and merged until all cable number cells do not span pages. In response to the completion of the cross-page adjustment, it is determined whether the first line of each page is a blank line. If so, the entire line is deleted to obtain a typesetting wiring diagram.
2. The automatic typesetting method for an EXCEL wiring diagram according to claim 1, wherein: The step of performing a cell merging operation and filling in serial numbers on the serial number column according to the merged cell information includes: According to the position of each merged cell, the corresponding merged starting row number in the sequence number column is obtained, and according to the merged starting row number, the cells corresponding to the number of merged cells in the sequence number column are merged from top to bottom to obtain each sequence number cell; Traverse each cell of the cable number column from top to bottom, and fill in the serial number cells corresponding to the cells with data in ascending order.
3. The automatic typesetting method for an EXCEL wiring diagram according to claim 1, wherein: The step of initializing the cells in the area to be typeset according to a preset standard includes: Initialize the row height of the area to be typeset to the initial row height; Initialize the font type, font size, font color and fill format of the cells in the area to be typeset to Songti, initial font size, black and automatic line break fill; Based on the cable number column, separation rows are set from top to bottom for adjacent cables in the area to be typed.
4. The automatic typesetting method for an EXCEL wiring diagram as claimed in claim 3, wherein: The step of setting separation rows for adjacent cables in the area to be typed from top to bottom based on the cable number column includes: Traverse the cells of the cable number column from top to bottom and determine whether each cell is a merged cell; If the cell is a merged cell and is the same merged cell as the serial number cell in the corresponding serial number column, the merged cell in the current row is split, and if it is determined that the next row of the current merged cell has no content, the next row is deleted; If the cell is a merged cell and is not the same merged cell as the cell in the corresponding serial number column, then when it is determined that the next row of the current merged cell has content, insert a row below the current row; If the cell is not a merged cell and has content, determine whether the next row of the current merged cell has content. If so, insert a row below the current row. If the cell is not a merged cell and has no content, determine whether the next row of the current merged cell has content. If not, delete the next row.
5. The automatic typesetting method for an EXCEL wiring diagram according to claim 3, wherein: The step of adjusting the row height of the cell to the target row height according to the data content of each cell in the area to be typeset includes: Traversing the cells to be adjusted in the area to be typeset in the order of rows first and columns later, calculating the relationship between the length of the character string of each cell to be adjusted and the multiple of the column width, determining the multiple of the row height for data display based on the multiple relationship, and determining whether each cell to be adjusted is a merged cell; If the cell to be adjusted is a merged cell and is the first cell of the merged cell, then when it is determined that the number of rows corresponding to the merged cell is less than the data display row height multiple, the cell average value of the current merged cell is calculated according to the data display row height multiple, and according to the cell average value and the current cell row height, the row heights of the corresponding rows of all cells in the current merged cell are adjusted to the corresponding target row height; If the cell to be adjusted is not a merged cell and the data display row height multiple is greater than the current cell row height, the row height of the row corresponding to the current cell is adjusted to the target row height corresponding to the data display row height multiple.
6. The automatic typesetting method for an EXCEL wiring diagram according to claim 5, wherein: The step of adjusting the row heights of all rows corresponding to cells in the current merged cell to the corresponding target row height according to the cell amortization value and the current cell row height includes: If the cell amortized value is greater than the current cell row height, the row heights of all corresponding rows of cells in the current merged cell are adjusted to the cell amortized value; If the cell amortized value is less than the current cell row height and the cell amortized value is greater than the initial row height, the total row height of the current merged cells is calculated, and when the total row height of the current merged cells is less than the row height corresponding to the data display row height multiple, the row height of the row corresponding to the current cell is kept unchanged, and the row heights of the rows corresponding to the remaining cells in the current merged cell are adjusted to the cell amortized value; If the cell amortized value is smaller than the initial row height, the row height of the current merged cell remains unchanged.
7. The automatic typesetting method for an EXCEL wiring diagram according to claim 1, wherein: The step of determining whether there are cable number cells that span pages based on the number of rows at each page break position, and if so, splitting and merging the corresponding cable number cells until all cable number cells do not span pages includes: If the cable number cell at the current page break position is a merged cell and the number of rows of the first cell of the merged cell is less than the number of rows of the current page break position, then insert blank rows before the merged cell to move the merged cell down until the number of rows of the first cell of the merged cell is equal to the number of rows of the current page break position; Get the row number of the next page break position, and determine whether the merged cell currently moving down spans pages based on the row number of the next page break position; If the merged cell currently moved down spans pages, the merged cell will be split and merged and the row height will be adjusted in the order of columns first and rows with the number of rows at the next page break position as the dividing line. When it is determined that the adjusted merged cell still spans pages, it will be reset and adjusted until the corresponding number of cables that do not span pages are obtained.
8. An automatic typesetting system for EXCEL wiring diagrams, characterized in that: The system comprises: An information acquisition module is used to acquire an EXCEL wiring diagram to be typeset, and obtain an area to be typeset based on the EXCEL wiring diagram to be typeset; A serial number filling module is used to traverse the cable number column from top to bottom in the area to be typeset, obtain the merged cell information of each cable number, and perform a cell merging operation and serial number filling on the serial number column according to the merged cell information; the merged cell information includes the merged cell position and the number of merged cells; An initial layout module, configured to initialize the cells in the area to be layout according to a preset standard in response to completion of the serial number column processing; A row height adjustment module, configured to adjust the row height of the cell to a target row height according to the data content of each cell in the area to be typeset in response to completion of the initialization setting; A page span adjustment module is configured to, in response to the completion of the row height adjustment, sequentially obtain the row numbers of each page break position in the area to be typeset, and determine from top to bottom based on the row numbers of each page break position whether there are cable number cells that span pages; if so, split and merge the corresponding cable number cells until all cable number cells do not span pages; The page adjustment module is used to judge whether the first line of each page is a blank line in response to the completion of the cross-page adjustment. If so, the entire line is deleted to obtain a typesetting wiring diagram.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Text table cross-page method of ScaleRichView editor
CN108804405A
Automatic composition system
JP2006085514A