CN115618819A - Excel and Dwg file interconversion method and device - Google Patents

Excel and Dwg file interconversion method and device Download PDF

Info

Publication number
CN115618819A
CN115618819A CN202211351948.2A CN202211351948A CN115618819A CN 115618819 A CN115618819 A CN 115618819A CN 202211351948 A CN202211351948 A CN 202211351948A CN 115618819 A CN115618819 A CN 115618819A
Authority
CN
China
Prior art keywords
dwg
file
excel
template
name
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211351948.2A
Other languages
Chinese (zh)
Inventor
杨怡
徐明卉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wisdri Engineering and Research Incorporation Ltd
Original Assignee
Wisdri Engineering and Research Incorporation Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wisdri Engineering and Research Incorporation Ltd filed Critical Wisdri Engineering and Research Incorporation Ltd
Priority to CN202211351948.2A priority Critical patent/CN115618819A/en
Publication of CN115618819A publication Critical patent/CN115618819A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/174Form filling; Merging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/177Editing, e.g. inserting or deleting of tables; using ruled lines
    • G06F40/18Editing, e.g. inserting or deleting of tables; using ruled lines of spreadsheets
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/189Automatic justification

Abstract

The invention discloses a method and a device for mutually converting Excel and Dwg files, wherein the method comprises the following steps: acquiring a name manager list of the Excel file, traversing all values of the list, comparing the values with the configured field prefix of the universal list, and judging whether the template file with the corresponding name in the Excel name manager list can be found in the Dwg template list; if the Excel file can be found, reading the configuration file of the Excel file and writing the configuration file into a corresponding Dwg template; if the template cannot be found, all Dwg templates are displayed to a user to manually select the corresponding template, and then the configuration file of the Excel file is read and written into the corresponding Dwg template; acquiring all text box name sequences of the combined box parts in the Excel file, and storing the text box name sequences into a header temporary table; and traversing Dwg attribute definitions of the graph and label block, matching, and storing the header temporary table data into the attribute value. The invention can realize the interconversion of Excel and Dwg files and improve the drawing efficiency.

Description

Excel and Dwg file interconversion method and device
Technical Field
The invention belongs to the field of construction drawing design, and particularly relates to a method and a device for converting Excel and Dwg files.
Background
The large-scale engineering project has the characteristics of tight project cycle, high construction requirement, large construction scale and the like, the design stage of the project is used as the foremost end of the whole industrial chain, the design stage has higher requirement on the design link of the construction drawing of an exploration design enterprise, the design workload is greatly increased, and a method for improving the design efficiency needs to be found. Standardization is an important basic condition for improving design quality and fine design, and convenience is an essential element for simplifying design modes and improving design efficiency.
At present, basically all design enterprises carry out two-dimensional drawing through computer software, and the drawing type is Dwg. However, the two-dimensional mapping software has the following defects:
1. aiming at part of drawings with special drawing formats, such as IO tables, terminal tables and the like, the drawing operation in drawing software is complex, and the design efficiency is influenced;
2. for form drawings, such as types of material tables, order lists, equipment tables, pipeline data tables and the like, operations such as row increase and decrease, copying, merging and the like are inconvenient, and the drawing time is seriously influenced;
3. for a small amount of calculation drawings such as a drawing catalog and the like, functions such as summarization and the like cannot be automatically calculated, and the probability of counting misoperation by designers is increased;
therefore, the two-dimensional drawing software is difficult to meet the application requirement of efficient drawing for drawing on the partial type drawing paper.
However, if the drawings of the above types are compiled and plotted by using an Excel format, the printing effect is difficult to guarantee due to more Excel versions, the standardized printing plotting difficulty is high, and the requirements of standard digital plotting cannot be met.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provides a method and a device for mutually converting Excel and Dwg files, which are used for mutually converting formats of Excel and Dwg files, can be compiled in an Excel file and then quickly and accurately converted into Dwg files for drawing, can convert Dwg files into Excel files for modifying and drawing, and improve the drawing efficiency.
The technical scheme of the invention is realized as follows: the invention discloses a method for converting an Excel file into a Dwg file, which comprises the following steps:
acquiring a name manager list of the Excel file, traversing all values of the list, comparing the values with the configured field prefix of the universal list, and judging whether the template file with the corresponding name in the Excel name manager list can be found in the Dwg template list;
if the Excel file can be found, reading the configuration file of the Excel file and writing the configuration file into a corresponding Dwg template;
if the template cannot be found, all Dwg templates are displayed to a user to manually select the corresponding template, and then the configuration file of the Excel file is read and written into the corresponding Dwg template;
acquiring all textbox name sequences of the combined frame part in the Excel file, and storing the textbox name sequences into a header temporary table;
and traversing all attribute definitions of the Dwg icon block, matching, and storing header temporary table data into an attribute value.
Further, when a template file with a corresponding name in an Excel name manager list can be found in a Dwg template list, opening the Dwg template to obtain an attribute definition mark with the template name as a block name, calculating Dwg single-row height of the template table, storing Excel file table content in a table temporary table, and writing the value in the table temporary table into Dwg in a row unit under the corresponding attribute mark.
Further, when the Excel file to be converted is of the order list type, an order list Dwg cover template is obtained, all text box name sequences of the combined frame parts in the Excel file are stored in the attribute definitions of the corresponding blocks, and an order list cover is generated.
Further, said calculating Dwg a single row height of the template table comprises: and subtracting the coordinate positions of two marks with the same name in the attribute definition mark to obtain a total line height, acquiring Dwg default layer names from the configuration file, identifying the type of the primitive on the layer as a straight line, taking the number of the straight lines with the angle not exceeding the positive and negative 5 degrees of the horizontal as the total line number, and dividing the total line height by the total line number to obtain a single line height value.
Further, the writing the values in the table temporary table into Dwg in units of rows and the corresponding attribute marked lower primitive positions further includes: and when the cell characters exceed the cell width of Dwg, carrying out format optimization by adopting an intelligent indentation algorithm.
Further, the writing the values in the table temporary table into Dwg in units of rows and the corresponding attribute marked lower primitive positions further includes: aiming at multi-line texts, the total height of written actual characters is required to be obtained, the horizontal straight line of a line pressing line is deleted, and meanwhile, the initial line number of the next line is calculated according to the position coordinate of the nearest horizontal straight line so as to realize the intelligent format optimization function.
The invention also discloses a device for converting the Excel file into the Dwg file, which specifically comprises the following steps:
the obtaining module is used for obtaining a name manager list of the Excel file and obtaining all text box name sequences of the combined frame parts in the Excel file;
the storage module is used for storing table contents of the Excel file into a table temporary table, storing all text box name sequences of the combined frame part in the Excel file into a header temporary table, and storing data of the header temporary table into an attribute value;
the conversion module is used for traversing all values of the list, finding a template file of a corresponding name in the Excel name manager in the Dwg template list, and opening the Dwg template to acquire an attribute definition mark with the template name as a block name; the table temporary table is used for calculating the height of a single row of the table, and then values in the table temporary table are written into the positions of the graphic elements under the corresponding attribute marks in Dwg in a row unit; all attribute definitions for traversing Dwg the tile and matching.
The invention also discloses a method for converting the Dwg file into the Excel file, which can convert the Dwg file into the Excel file after converting the Excel into the Dwg file by the method, and comprises the following steps: and identifying Dwg image block information by a plug-in tool, matching corresponding Excel templates, reading configuration files, writing the configuration files into the Excel templates, and then performing file conversion.
Further, identifying Dwg image block information by a plug-in tool, matching corresponding Excel templates, reading configuration files, writing the configuration files into the Excel templates, and then performing file conversion specifically comprises the following steps:
acquiring a block attribute definition list of a Dwg file, traversing all values of the list, comparing with a configured field prefix of a general table, and storing attribute definition names and coordinate positions corresponding to matching items in a configuration table into a temporary table;
finding a corresponding file in an Excel template list, and opening a name manager list of the template;
recording Dwg row number, and writing the value in the table temporary table into the corresponding column and sequence number row of the name manager list in Excel in row unit;
acquiring Dwg block attribute definitions of the graph label part, and storing the attribute definitions into a header temporary table;
and traversing all the text box name sequences of the combined box part in the Excel file, matching, and storing the header temporary table data into the attribute value.
The invention also discloses a device for converting the Dwg file into the Excel file, which comprises the following components:
the acquisition module is used for acquiring a block attribute definition list of a Dwg file; all attribute definitions of the blocks used for obtaining the Dwg icon part;
the storage module is used for storing the attribute definition names and the coordinate positions corresponding to the matching items in the configuration table into a table temporary table; the table header temporary table is used for storing all attribute definitions of the blocks of the Dwg icon part into the table header temporary table; the attribute value is used for storing the header temporary table data;
the conversion module is used for traversing all values of the list, comparing the values with the configured field prefix of the universal table, finding a corresponding file in the Excel template list, opening the name manager list of the template, recording Dwg row numbers, and writing the values in the temporary table of the table into a corresponding column and a sequence number row of the name manager list in the Excel in a row unit; and traversing all the text box name sequences of the combined box parts in the Excel file and matching.
Compared with the prior art, the invention mainly has the following advantages:
the method is much less flexible and convenient than Excel in editing table files in Dwg format, and the method supports mutual conversion of two files, so that the drawing efficiency can be remarkably improved, and the accuracy can be ensured.
2. In the prior art, the format needs to be manually adjusted after conversion, intelligent indentation and multi-line text automatic optimization functions are added, and the format can be automatically indented and adjusted after conversion to a new format aiming at the condition that the content of a cell is more, so that the repeated workload is reduced.
3. The invention can be applied to two-dimensional drawing software CAD of multiple versions such as 2007, 2014, 2021 and the like so as to meet the design habit of designers using different drawing software.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a system diagram of an Excel and Dwg file inter-conversion plug-in tool according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for interconversion between Excel and Dwg files according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1 and fig. 2, the invention discloses a method and a device for interconversion of Excel and Dwg files. Firstly, a plug-in tool for performing Excel and Dwg conversion on general type files and special type files is deployed in two-dimensional drawing software (such as 2007, 2014, 2021 and other CAD with multiple versions). Secondly, an administrator defines names and image blocks according to the requirements of configuration files, makes multiple types of Excel and Dwg templates, synchronizes to a client through a plug-in tool, realizes that the Excel and Dwg files can be mutually converted even in a single off-line state, and needs to be networked to use the plug-in tool if the templates are not synchronized to the client.
Setting templates corresponding to Excel and Dwg for a drawing of a general form type, positioning label information to corresponding row-column cells, ensuring that the Excel and Dwg cells are in one-to-one correspondence, and writing a file header (including drafts, professional information, drawing date, project information, audit information, drawing numbers, security levels and other information) in an Excel format and form contents into Dwg template files during conversion; for drawings of types of different types of tables (such as IO tables, terminal tables and the like), the table types and the cell positions are recorded through a configuration file, and the table content of Excel is written into a Dwg file.
After a user selects a required Excel template to edit and draw, one or more excels are uploaded to a conversion plug-in tool, the plug-in tool matches a corresponding template according to the Excel attribute name, then a configuration file of an Excel file is read and written into a corresponding Dwg template to perform file conversion, and the method specifically comprises the following steps: and acquiring a name manager list of the Excel file, traversing all values of the list, comparing the values with the configured field prefix of the universal list, and judging whether the template file with the corresponding name in the Excel name manager list can be found in the Dwg template list.
If the template file with the corresponding name in the Excel name manager list can be found in the Dwg template list, reading the configuration file of the Excel file and writing the configuration file into the corresponding Dwg template; at the moment, the Excel file is of a universal table type or an order list type, and a column attribute configuration file of a read universal table is written into a corresponding Dwg template; the method specifically comprises the following steps: when the template file of the corresponding name in the Excel name manager list can be found in the Dwg template list, opening the Dwg template to obtain the attribute definition mark taking the template name as the block name, calculating Dwg single-line height of the template table, storing the Excel file table content in the table temporary table, and writing the value in the table temporary table into Dwg at the position of the primitive under the corresponding attribute mark in the line unit. And storing the cell contents of the Excel file into a temporary table of the table in a column mode.
The calculating Dwg a single row height of the template table comprises: and subtracting the coordinate positions of two marks with the same name in the attribute definition mark to obtain a total line height, acquiring Dwg default layer names from the configuration file, identifying the type of the primitive on the layer as a straight line, taking the number of the straight lines with the angle not exceeding the positive and negative 5 degrees of the horizontal as the total line number, and dividing the total line height by the total line number to obtain a single line height value.
And when the cell text exceeds the cell width of Dwg, carrying out format optimization by adopting an intelligent indentation algorithm. The method comprises the following specific steps: obtaining the positions of the two nearest vertical lines according to the coordinate information of the column attribute marks on the layer to obtain the corresponding column width; and calculating the actual character width of each row of the row, if the actual character width exceeds the row width, judging at intervals of every 0.1 until the character width does not exceed the row width, and the width factor is not less than 0.6 at the minimum, otherwise, displaying double images on the characters. If the last line number of a single Dwg has been written, then the automatically new Dwg template continues writing.
Aiming at multi-line texts, the total height of written actual characters is required to be obtained, the horizontal straight line of a line pressing line is deleted, and meanwhile, the initial line number of the next line is calculated according to the position coordinate of the nearest horizontal straight line so as to realize the intelligent format optimization function.
If the template file with the corresponding name in the Excel name manager list cannot be found in the Dwg template list, all Dwg templates are displayed to a user to manually select the corresponding template, the configuration file of the Excel file is read, and the corresponding Dwg template is written; the Excel file is of the heteromorphic table type at this time.
Then, acquiring all text box name sequences of the combined box parts in the Excel file by the plug-in tool, and storing the text box name sequences into a header temporary table; and traversing Dwg attribute definitions of the graph and label block, matching, and storing the header temporary table data into the attribute value for conversion.
When the Excel file to be converted is of the order list type, an order list Dwg cover template is obtained, all text box name sequences of the combined frame parts in the Excel file are stored in the attribute definitions of the corresponding blocks, and an order list cover is generated.
In the case of multiple excels, the user selects whether to generate one Dwg or split into multiple single frames Dwg.
If the conversion is successful, generating Dwg files and result logs; if the conversion fails, a result log is generated to explain the failure reason.
The invention also discloses a device for converting the Excel file into the Dwg file, which specifically comprises the following steps:
the obtaining module is used for obtaining a name manager list of the Excel file and obtaining all text box name sequences of the combined frame parts in the Excel file;
the storage module is used for storing table contents of the Excel file into a table temporary table, storing all text box name sequences of the combined frame part in the Excel file into a header temporary table, and storing data of the header temporary table into an attribute value;
the conversion module is used for traversing all values of the list, finding a template file of a corresponding name in the Excel name manager in the Dwg template list, and opening the Dwg template to acquire an attribute definition mark with the template name as a block name; the table temporary table is used for calculating the height of a single row of the table, and then values in the table temporary table are written into the positions of the graphic elements under the corresponding attribute marks in Dwg in a row unit; all attribute definitions for traversing Dwg the tile and matching.
The invention also discloses a method for converting the Dwg file into the Excel file, and one or more universal type Dwg files converted by the tool can be converted into the Excel after being edited and modified; the tool identification Dwg image block information matches with corresponding Excel, and a configuration file is read; writing the general table content of the general type Dwg file into an Excel template, and if the conversion is successful, generating an Excel file and a result log; if the conversion fails, a result log is generated to explain the failure reason.
Identifying Dwg image block information by a plug-in tool, matching corresponding Excel templates, reading configuration files, writing the configuration files into the Excel templates, and then performing file conversion, wherein the specific steps of the method are as follows:
acquiring a block attribute definition list of a Dwg file, traversing all values of the list, comparing with a configured field prefix of a general table, and storing attribute definition names and coordinate positions corresponding to matching items in a configuration table into a temporary table; storing the Excel cell contents into a table temporary table in a column mode;
finding a corresponding file in an Excel template list, and opening a name manager list of the template;
recording Dwg row numbers, acquiring the Dwg default layer name from a configuration file, identifying the primitive type on the layer as straight lines, recording the coordinate position of each straight line, and performing sequence coding, wherein the angle of each straight line does not exceed the number of the straight lines with the positive and negative 5 degrees horizontally;
writing the values in the temporary table of the table into corresponding columns and serial number rows of a name manager list in the Excel in a row unit;
acquiring Dwg block attribute definitions of the graph label part, and storing the attribute definitions into a header temporary table;
and traversing all the text box name sequences of the combined box part in the Excel file, matching, and storing the header temporary table data into the attribute value.
The invention also discloses a device for converting the Dwg file into the Excel file, which comprises the following components:
the acquisition module is used for acquiring a block attribute definition list of a Dwg file; all attribute definitions of the blocks used for obtaining the Dwg icon part;
the storage module is used for storing the attribute definition names and the coordinate positions corresponding to the matching items in the configuration table into a temporary table; the table header temporary table is used for storing all attribute definitions of the blocks of the Dwg icon part into the table header temporary table; the table header temporary table data is stored into the attribute value;
the conversion module is used for traversing all values of the list, comparing the values with the configured field prefix of the general table, finding a corresponding file in an Excel template list, opening a name manager list of the template, recording Dwg row numbers, and writing the values in the table temporary table into a corresponding column and a serial number row of the name manager list in the Excel in a row unit; and traversing all the text box name sequences of the combined box parts in the Excel file and matching.
In order to better explain the technical solution of the present application, several examples will be listed below for explanation.
Example 1
Converting the general table type Excel file into a Dwg file, which comprises the following specific steps:
the method comprises the steps that a program obtains a name manager list of an Excel file, traverses all values of the list, compares the values with a configured field prefix of a general table, and stores table contents of the Excel file into a table temporary table, specifically comprises the steps of storing names and reference position relations of name managers corresponding to matching items in a configuration table into the table temporary table, and storing cell contents in the reference position relations into the table temporary table in a column mode;
finding a template file corresponding to a name in an Excel name manager in a Dwg template list, opening the Dwg template to acquire an attribute definition mark with the template name as a block name;
calculating Dwg template table single-row height, specifically comprising: subtracting the coordinate positions of two marks with the same name in the attribute definition mark to obtain a total line height, acquiring Dwg default layer names from the configuration file, identifying primitive types on the layer as straight lines, taking the number of the straight lines with the angle not exceeding the positive and negative 5 degrees of the horizontal as the total line number, and dividing the total line height by the total line number to obtain a single line height value;
writing the values in the temporary table into Dwg in row units, wherein the primitive under the corresponding attribute mark is the position of a single-row character; if the last row number of a single Dwg is written, automatically creating a Dwg template and continuously writing; if the text is a multi-line text, automatically optimizing the format, specifically comprising: and acquiring the total height of the written actual characters, deleting the horizontal straight line of the line pressing line, and calculating the initial line number of the next line according to the position coordinate of the nearest horizontal straight line.
When the cell characters exceed Dwg cell width, the format optimization is performed by adopting an intelligent indentation algorithm, which specifically comprises the following steps: obtaining the positions of the two nearest vertical lines according to the coordinate information of the column attribute marks on the layer to obtain the corresponding column width; calculating the actual character width of each row in the row, if the actual character width exceeds the row width, judging at intervals of every 0.1 until the character width does not exceed the row width, and the minimum width factor is not less than 0.6, otherwise, displaying double images on the characters;
the program obtains all text box name sequences of the combined box parts in the Excel file and stores the text box name sequences into a header temporary table;
traversing Dwg all attribute definitions of the graph-label block, matching, and storing the data of the header temporary table into the attribute value.
Example 2
Converting the order list type Excel file into a Dwg file, which comprises the following specific steps:
the method comprises the steps that a program obtains a name manager list of an Excel file, traverses all values of the list, compares the values with a configured universal table field prefix, and stores the name and reference position relation of a name manager corresponding to a matching item in a configuration table;
storing the cell contents in the reference position relationship into a table temporary table in a column mode;
finding a template file corresponding to a name in an Excel name manager in a Dwg template list, opening the Dwg template to acquire an attribute definition mark with the template name as a block name;
calculating Dwg template table single-row height, specifically comprising: subtracting the coordinate positions of two marks with the same name in the attribute definition mark to obtain a total line height, acquiring Dwg default layer names from the configuration file, identifying primitive types on the layer as straight lines, taking the number of the straight lines with the angle not exceeding the positive and negative 5 degrees of the horizontal as the total line number, and dividing the total line height by the total line number to obtain a single line height value;
writing the values in the temporary table into Dwg according to the line as a unit, wherein the primitive under the corresponding attribute mark is the position of a plurality of lines of characters; if the last row number of a single Dwg is written, automatically creating a Dwg template and continuing writing;
acquiring the total height of written actual characters, deleting horizontal straight lines of line pressing lines, and calculating the initial line number of the next line according to the position coordinates of the nearest horizontal straight line;
when the cell characters exceed Dwg cell width, the format optimization is performed by adopting an intelligent indentation algorithm, which specifically comprises the following steps: obtaining the positions of the two nearest vertical lines according to the coordinate information of the column attribute marks on the layer to obtain the corresponding column width; calculating the actual character width of each line of the row, if the actual character width exceeds the row width, judging at intervals of every 0.1 until the character width does not exceed the row width, and the width factor is not less than 0.6 at the minimum, otherwise, displaying double images on the characters;
the program obtains all text box name sequences of the combined box parts in the Excel file and stores the text box name sequences into a header temporary table;
traversing Dwg attribute definitions of the graph-label block, and storing header temporary table data into an attribute value after matching;
the program obtains the order list Dwg cover template, and stores all the text box name sequences of the combined box parts in the Excel file into the attribute definition of the corresponding block to generate an order list cover.
Example 3
The method for converting the special-shaped table type Excel file into the Dwg file comprises the following specific steps:
the method comprises the steps that a program obtains a character string which is a template name in a name manager of an Excel file, the character string finds a corresponding Dwg template name and a file type of a matching item in an abnormal table configuration item, and if the template is not needed by a user, all templates of the file type are displayed for the user to select; in the special-shaped table, one Excel template header can correspond to a plurality of Dwg template headers;
reading the configuration item of the file type in the special-shaped corresponding relation table, and writing the attribute definition mark of the corresponding block Dwg in the cell code of each string of data;
the program obtains all text box name sequences of the combined box parts in the Excel file and stores the text box name sequences into a header temporary table;
and traversing Dwg attribute definitions of the graph and label block, and storing the header temporary table data into the attribute value after matching.
Example 4
The invention also discloses a device for converting the Excel file into the Dwg file, which specifically comprises the following steps:
the obtaining module is used for obtaining a name manager list of the Excel file and obtaining all text box name sequences of the combined frame parts in the Excel file;
the storage module is used for storing the name and the reference position relation of the name manager corresponding to the matching item in the configuration table into a table temporary table, storing all text box name sequences of the combined frame part in the Excel file into a header temporary table, and storing data of the header temporary table into an attribute value;
the conversion module is used for traversing all values of the list, finding a template file of a corresponding name in the Excel name manager in the Dwg template list, and opening the Dwg template to acquire an attribute definition mark with the template name as a block name; the table temporary table is used for calculating the height of a single row of the table, and then values in the table temporary table are written into the positions of the graphic elements under the corresponding attribute marks in Dwg in a row unit; all attribute definitions for traversing Dwg counternotes and matching.
Example 5
The invention also discloses a method for converting the Dwg file into the Excel file, which can convert the Dwg file into the Excel file after converting the Excel into the Dwg file by the method, and comprises the following steps: and identifying Dwg image block information by a plug-in tool, matching corresponding Excel templates, reading configuration files, writing the configuration files into the Excel templates, and then performing file conversion.
The method comprises the following specific steps:
the program acquires a block attribute definition list of a Dwg file, traverses all values of the list, compares the values with the prefix of the configured universal table field, and stores attribute definition names and coordinate positions corresponding to matching items in a configuration table into a temporary table; storing the cell contents in the coordinate position relationship into a table temporary table according to a column mode;
finding a corresponding file in an Excel template list, and opening a name manager list of the template;
record Dwg row number, which specifically includes: acquiring the Dwg default layer name from a configuration file, identifying the primitive type on the layer as straight lines, recording the coordinate position of each straight line, and performing sequence coding, wherein the angle of each straight line does not exceed the number of the straight lines with the angle of plus or minus 5 degrees horizontally;
writing the values in the temporary table of the table into corresponding columns and serial number rows of a name manager list in the Excel in a row unit;
the program acquires Dwg all attribute definitions of the blocks of the graph and label part and stores the attribute definitions into a header temporary table;
and traversing all the text box name sequences of the combined box part in the Excel file, matching, and storing the header temporary table data into the attribute value.
Example 6
The invention also discloses a device for converting the Dwg file into the Excel file, which comprises the following components:
the acquisition module is used for acquiring a block attribute definition list of a Dwg file; all attribute definitions of the blocks used for obtaining the Dwg icon part;
the storage module is used for storing the attribute definition names and the coordinate positions corresponding to the matching items in the configuration table into a table temporary table; the table header temporary table is used for storing all attribute definitions of the blocks of the Dwg icon part into the table header temporary table; the table header temporary table data is stored into the attribute value;
the conversion module is used for traversing all values of the list, comparing the values with the configured field prefix of the general table, finding a corresponding file in an Excel template list, opening a name manager list of the template, recording Dwg row numbers, and writing the values in the table temporary table into a corresponding column and a serial number row of the name manager list in the Excel in a row unit; and traversing all the text box name sequences of the combined box parts in the Excel file and matching.
The plug-in tool is installed in two-dimensional drawing software to realize fast file conversion between Excel and Dwg, and mainly comprises a general table type Excel to Dwg function, an order list type Excel to Dwg function, a special table type Excel to Dwg function and a general table type Dwg to Excel function, wherein the order list type Excel to Dwg function is similar to the general table type Excel to Dwg function, but an order list cover is additionally generated. The invention also has the function of automatically optimizing the format for multi-line texts.
It should be understood that the specific order or hierarchy of steps in the processes disclosed is an example of exemplary approaches. Based upon design preferences, it is understood that the specific order or hierarchy of steps in the processes may be rearranged without departing from the scope of the present disclosure. The accompanying method claims present elements of the various steps in a sample order, and are not intended to be limited to the specific order or hierarchy presented.
In the foregoing detailed description, various features are grouped together in a single embodiment for the purpose of streamlining the disclosure. This method of disclosure is not to be interpreted as reflecting an intention that the claimed embodiments of the subject matter require more features than are expressly recited in each claim. Rather, as the following claims reflect, invention lies in less than all features of a single disclosed embodiment. Thus, the following claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be integral to the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. Of course, the processor and the storage medium may reside as discrete components in a user terminal.
For a software implementation, the techniques described herein may be implemented with modules (e.g., procedures, functions, and so on) that perform the functions described herein. The software codes may be stored in memory units and executed by processors. The memory unit may be implemented within the processor or external to the processor, in which case it can be communicatively coupled to the processor via various means as is known in the art.
What has been described above includes examples of one or more embodiments. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the aforementioned embodiments, but one of ordinary skill in the art may recognize that many further combinations and permutations of various embodiments are possible. Accordingly, the embodiments described herein are intended to embrace all such alterations, modifications and variations that fall within the scope of the appended claims. Furthermore, to the extent that the term "includes" is used in either the detailed description or the claims, such term is intended to be inclusive in a manner similar to the term "comprising" as "comprising" is interpreted when employed as a transitional word in a claim. Furthermore, the term "or" as used in any one of the claims and the specification is intended to mean a "non-exclusive or".
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (10)

1. A method for converting an Excel file into a Dwg file, which is characterized by comprising the following steps:
acquiring a name manager list of the Excel file, traversing all values of the list, comparing the values with the configured field prefix of the general table, and judging whether the template file with the corresponding name in the Excel name manager list can be found in a Dwg template list or not;
if the Excel file can be found, reading the configuration file of the Excel file and writing the configuration file into a corresponding Dwg template;
if the template cannot be found, all Dwg templates are displayed to a user to manually select the corresponding template, and then the configuration file of the Excel file is read and written into the corresponding Dwg template;
acquiring all text box name sequences of the combined box parts in the Excel file, and storing the text box name sequences into a header temporary table;
and traversing Dwg attribute definitions of the graph and label block, matching, and storing the header temporary table data into the attribute value.
2. The method for converting Excel file into Dwg file according to claim 1, wherein when a template file with a corresponding name in Excel name manager list can be found in Dwg template list, opening Dwg template to obtain an attribute definition mark with template name as block name, calculating single row height of Dwg template table, storing Excel file table content into table temporary table, and writing the value in table temporary table into the primitive position under the corresponding attribute mark in Dwg in row unit.
3. The method for converting an Excel file into a Dwg file as claimed in claim 2, wherein when the Excel file to be converted is of order list type, obtaining an order list Dwg cover template, storing all textbox name sequences of combined frame parts in the Excel file into attribute definitions of corresponding blocks, and generating an order list cover.
4. The method for converting an Excel file into a Dwg file as claimed in claim 2, wherein said calculating a single row height of Dwg template table comprises: and subtracting the coordinate positions of two marks with the same name in the attribute definition mark to obtain a total line height, acquiring Dwg default layer names from the configuration file, identifying the type of the primitive on the layer as a straight line, taking the number of the straight lines with the angle not exceeding the positive and negative 5 degrees of the horizontal as the total line number, and dividing the total line height by the total line number to obtain a single line height value.
5. The method for converting an Excel file into a Dwg file as claimed in claim 2, wherein the writing the values in the table temporary table into the corresponding attribute labeled lower primitive position in Dwg in row unit further comprises: and when the cell characters exceed the cell width of Dwg, carrying out format optimization by adopting an intelligent indentation algorithm.
6. The method for converting an Excel file into a Dwg file according to claim 2, wherein said writing the values in the table temporary table in units of lines into Dwg corresponding attribute labeled lower primitive position further comprises: aiming at multi-line texts, the total height of written actual characters is required to be obtained, the horizontal straight line of a line pressing line is deleted, and meanwhile, the initial line number of the next line is calculated according to the position coordinate of the nearest horizontal straight line so as to realize the intelligent format optimization function.
7. An apparatus for converting Excel files into Dwg files is characterized by specifically comprising:
the obtaining module is used for obtaining a name manager list of the Excel file and obtaining all text box name sequences of the combined frame parts in the Excel file;
the storage module is used for storing table contents of the Excel file into a table temporary table, storing all text box name sequences of the combined frame part in the Excel file into a header temporary table and storing data of the header temporary table into an attribute value;
the conversion module is used for traversing all values of the list, finding a template file of a corresponding name in the Excel name manager in the Dwg template list, and opening the Dwg template to acquire an attribute definition mark with the template name as a block name; the table temporary table is used for calculating the height of a single row of the table, and then values in the table temporary table are written into the positions of the graphic elements under the corresponding attribute marks in Dwg in a row unit; all attribute definitions for traversing Dwg the tile and matching.
8. A method for converting Dwg file into Excel file, which is characterized in that after Excel is converted into Dwg file by the method of claims 1 to 6, the Dwg file can also be converted into Excel file, comprising: and identifying Dwg image block information by a plug-in tool, matching corresponding Excel templates, reading configuration files, writing the configuration files into the Excel templates, and then performing file conversion.
9. The method for converting Dwg files into Excel files according to claim 8, wherein the specific steps of identifying Dwg graphic block information by a plug-in tool and matching with a corresponding Excel template, reading configuration files and writing the configuration files into the Excel template, and then performing file conversion are as follows:
acquiring a block attribute definition list of a Dwg file, traversing all values of the list, comparing with a configured field prefix of a general table, and storing attribute definition names and coordinate positions corresponding to matching items in a configuration table into a temporary table;
finding a corresponding file in an Excel template list, and opening a name manager list of the template;
recording Dwg row number, and writing the value in the table temporary table into the corresponding column and sequence number row of the name manager list in Excel in row unit;
acquiring Dwg block attribute definitions of the graph label part, and storing the attribute definitions into a header temporary table;
and traversing all the text box name sequences of the combined box part in the Excel file, matching, and storing the header temporary table data into the attribute value.
10. An apparatus for converting Dwg file into Excel file, comprising:
the acquisition module is used for acquiring a block attribute definition list of a Dwg file; all attribute definitions of the blocks used to obtain the Dwg icon part;
the storage module is used for storing the attribute definition names and the coordinate positions corresponding to the matching items in the configuration table into a table temporary table; the table header temporary table is used for storing all attribute definitions of the blocks of the Dwg icon part into the table header temporary table; the table header temporary table data is stored into the attribute value;
the conversion module is used for traversing all values of the list, comparing the values with the configured field prefix of the general table, finding a corresponding file in an Excel template list, opening a name manager list of the template, recording Dwg row numbers, and writing the values in the table temporary table into a corresponding column and a serial number row of the name manager list in the Excel in a row unit; and traversing all the text box name sequences of the combined box parts in the Excel file and matching.
CN202211351948.2A 2022-10-31 2022-10-31 Excel and Dwg file interconversion method and device Pending CN115618819A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211351948.2A CN115618819A (en) 2022-10-31 2022-10-31 Excel and Dwg file interconversion method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211351948.2A CN115618819A (en) 2022-10-31 2022-10-31 Excel and Dwg file interconversion method and device

Publications (1)

Publication Number Publication Date
CN115618819A true CN115618819A (en) 2023-01-17

Family

ID=84876811

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211351948.2A Pending CN115618819A (en) 2022-10-31 2022-10-31 Excel and Dwg file interconversion method and device

Country Status (1)

Country Link
CN (1) CN115618819A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115841679A (en) * 2023-02-23 2023-03-24 江西中至科技有限公司 Drawing sheet extraction method, system, computer and readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115841679A (en) * 2023-02-23 2023-03-24 江西中至科技有限公司 Drawing sheet extraction method, system, computer and readable storage medium
CN115841679B (en) * 2023-02-23 2023-05-05 江西中至科技有限公司 Drawing form extraction method, drawing form extraction system, computer and readable storage medium

Similar Documents

Publication Publication Date Title
JP4634101B2 (en) A method of accessing information captured during a presentation using a paper document distribution for the presentation
CN105631393A (en) Information recognition method and device
CN115618819A (en) Excel and Dwg file interconversion method and device
CN112181854B (en) Method, device, equipment and storage medium for generating process automation script
CN112084748A (en) Text comparison method
CN107908843B (en) Management system based on drawing of map label information
CN111666114A (en) Plug-in type well logging data conversion method
CN111523382B (en) Self-recording paper data acquisition method for rain gauge
CN115587098A (en) Method and system for intelligently identifying chart data
CN111178031A (en) Method for automatically generating anemometer tower data report
CN114996212A (en) Method, apparatus, device, and medium for managing elements in electronic book
CN108960054A (en) A kind of clearance data generation system and method based on picture and text identification
CN110941947A (en) Document editing method and device, computer storage medium and terminal
CN114937279A (en) BOM recognition method and device for realizing IA based on RPA and AI
JP5720182B2 (en) Image processing apparatus and image processing program
CN110675729B (en) Multi-version local geographic information integrated drawing method and system
CN114443657A (en) Spatial data layer field checking method and system applied to digital twin city
CN115202542B (en) Automatic link and skip method for circuit ports in electronic drawing based on OCR technology
KR100250978B1 (en) Method for converting autocad drawing to infomap drawing
CN116126790B (en) Railway engineering archive archiving method and device, electronic equipment and storage medium
CN116933143B (en) Flight parameter data classification method
CN114722464B (en) Automatic image examination system and method based on artificial intelligence
CN116704531A (en) Financial statement detection method based on lightweight YOLO model
CN110879721B (en) Method and device for generating help document
CN114359567A (en) Feature data extraction method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination