CN110187916A - The method for generating Word document based on data configuration - Google Patents
The method for generating Word document based on data configuration Download PDFInfo
- Publication number
- CN110187916A CN110187916A CN201910468240.7A CN201910468240A CN110187916A CN 110187916 A CN110187916 A CN 110187916A CN 201910468240 A CN201910468240 A CN 201910468240A CN 110187916 A CN110187916 A CN 110187916A
- Authority
- CN
- China
- Prior art keywords
- document
- word
- word document
- format
- file
- 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.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/166—Editing, e.g. inserting or deleting
- G06F40/186—Templates
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/73—Program documentation
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Abstract
The present invention relates to the generation techniques of Word document, it discloses it is a kind of based on data configuration generate Word document method, solves the problems, such as in traditional technology directly access Basic API generate Word document by way of existing for technical requirements height, size of code is big, reusability is low.Method includes the following steps: a. configures Word template directory file;B. the JSON file of specified format is configured;C. order line, resolve command row parameter and verification command row format are executed;D. JSON file is transmitted, distribution command simultaneously activates Word generator;E. it is inputted according to order line, parses JSON file content, verify the legitimacy and validity of JSON file format and content;F. Word template directory path is obtained according to JSON file content, reads Word template directory file content;G. it according to the Word template directory file content of reading, creates new Word document and fills document content;H. Word document is saved.The present invention is quickly generated suitable for Word document.
Description
Technical field
The present invention relates to the generation technique of Word document, in particular to a kind of side that Word document is generated based on data configuration
Method.
Background technique
During program or software development, the generation that needs that Word Basic API is called just to be able to achieve Word document.Mesh
Preceding most of developers mainly pass through directly access Basic API and generate Word document, and developer needs to Word Basic API
Interface is familiar with, including Word document section number, outline grade and content, content of text and format, image content and ginseng
The functions such as number replacement, while also needing to write more complicated code and being achieved, size of code is big, and logic is relative complex.
Although can satisfy requirement by way of directly accessing Basic API and generating Word document, there is following lack
Point:
1) developer needs to be familiar with Word Basic API interface, and logic is complicated, and technical requirements are higher;
2) developer needs to write a large amount of program codes, and process is complicated, inefficiency;
3) there are a large amount of duplicated codes, reusing degree is lower, maintainable poor.
Summary of the invention
The technical problems to be solved by the present invention are: providing a kind of method for generating Word document based on data configuration, solution
Certainly in traditional technology by way of directly accessing Basic API and generating Word document existing for it is high to technical requirements, size of code is big,
The low problem of reusability.
The technical proposal adopted by the invention to solve the above technical problems is that:
The method for generating Word document based on data configuration, comprising the following steps:
A. Word template directory file is configured;
B. the JSON file of specified format is configured;
C. order line, resolve command row parameter and verification command row format are executed;
D. JSON file is transmitted, distribution command simultaneously activates Word generator;
E. it is inputted according to order line, parses JSON file content, verify the legitimacy of JSON file format and content and had
Effect property;
F. Word template directory path is obtained according to JSON file content, reads Word template directory file content;
G. it according to the Word template directory file content of reading, creates new Word document and fills document content;
H. word document is saved.
As advanced optimizing, in step a, the Word template directory file includes: Word document structure category, document
Format category, table format catalogue, document picture directory, document section reduce catalogue and document parameter list.
This programme describes the detailed composition for the Word template directory file to be configured, by these Word template directories
The configuration of file can be called in program or project using command line mode, to beat for efficiently producing for Word document
Lower basis.
As advanced optimizing, in step b, the JSON file of the specified format include: Word document storing path,
Word document template directory path, Word document picture directory path, Word text category path and Word reduce directory path.
The detailed composition that the JSON file for the specified format to be configured is described in this programme, by these JSON files
Configuration, can be called in program or project using command line mode, to lay for efficiently producing for Word document
Basis.
As advanced optimizing, step f is specifically included:
1) file path is reduced according to document, obtains document and reduces set;
2) by recursive call, Word document tree-structure object is obtained;
3) by document format root path, the list of Word document format object is obtained;
4) by document picture root path, document tree object picture set is obtained;
5) by document text parameter path, document tree text parameter object set is obtained.
In the present solution, corresponding catalogue file content is obtained by each directory path of Word template, consequently facilitating
Word document is simply and efficiently created according to these contents and fills corresponding contents.
As advanced optimizing, step g is specifically included:
1) according to target Word document title in JSON, new Word document is created;
2) pass through incoming file catalogue structure objects and document picture object set, recursive generation Word document;
3) Word document format is set;
4) Word document text parameter is set;
5) Word document head and catalogue are set.
In the present solution, new Word document is automatically created by target Word document title in JSON, automatically according to document
Bibliographic structure object and document object picture carry out fills to newly-built Word document, to simplify operation.
The beneficial effects of the present invention are:
Developer only need to simply configure Word template directory file and specified format JSON file, so that it may
It is accessed by command line mode, realizes the function of automatically generating Word document, can be widely used in and need to generate
In the project and program of Word document, solves directly big, the code reuse degree using development difficulty caused by Word Basic API
It is low, it is at high cost the problems such as, effectively improve user generate Word document efficiency.
Detailed description of the invention
Fig. 1 is the method flow diagram that Word document is generated based on data configuration in the present invention.
Specific embodiment
The present invention is intended to provide a kind of method for generating Word document based on data configuration, solves in traditional technology by straight
Receiving asks that Basic API generates existing for the mode of Word document to the problem that technical requirements are high, size of code is big, reusability is low.Its
Core concept is: configuring, provides for execution order line defeated to Word template directory file and specified format JSON file
Enter information;After executing order line parsing, the data of configuration are called according to the JSON parameter of parsing to create Word document
And corresponding contents are filled, the final generation for realizing easy, efficient Word document.
As shown in Figure 1, in the present invention based on data configuration generate Word document method the following steps are included:
1. configuring Word template directory file;
2. configuring the JSON file of specified format;
3. executing order line, resolve command row parameter and verification command row format;
4. transmitting JSON file, distribution command simultaneously activates Word generator;
5. inputting according to order line, JSON file content is parsed, verify the legitimacy of JSON file format and content and is had
Effect property;
6. obtaining Word template directory path according to JSON file content, Word template directory file content is read;
7. creating new Word document according to the Word template directory file content of reading and filling document content;
8. saving word document.
Embodiment:
Step 1: configuring Word template directory file, including file structure catalogue, document format catalogue, table according to demand
Lattice format category, document picture directory, document section reduce the relevant informations such as catalogue, document parameter list.
Step 2: the JSON file of configuration specified format, including Word document storing path, Word document template directory road
Diameter, Word document picture directory path, Word text category path and Word reduce directory path etc..
Step 3: order line is executed, resolve command row data:
1) routine call order line executes method, format are as follows: and "-t word-p json file path ", such as :-t word-p
“e:\project\wordJson.json”。
2) order line is executed, judges whether order row format is correct.
Step 4: transmitting JSON file, distribution command call Word generator by reflection;
Step 5: parsing JSON file content, whether verifying content is correct, including just whether verifying JSON file format
Really, whether effective path in JSON file content is verified;
Step 6: obtaining template directory path according to JSON file content, Word template directory file content is read.
1) file path is reduced according to document, obtains document and reduces set
2) by recursive call, Word document tree-structure object (incoming parameter file structure root path, father node are obtained
Object, current ID and outline grade).
3) it by document format root path, obtains the list of Word document format object and (obtains every level-one outline format and big
Guiding principle content format).
4) by document picture root path, document tree object picture set is obtained.
5) by document text parameter path, document tree text parameter object set is obtained.
Step 7: obtaining Word document path according to JSON file content, new Word document is created, is filled in document
Hold.
1) according to target Word document title in JSON, new Word document is created.
2) pass through incoming file catalogue structure objects and document picture object set, recursive generation Word document.
3) Word document format is set.
4) Word document text parameter is set.
5) Word document head and catalogue are set.
Step 8: saving Word document.
Claims (5)
1. the method for generating Word document based on data configuration, which comprises the following steps:
A. Word template directory file is configured;
B. the JSON file of specified format is configured;
C. order line, resolve command row parameter and verification command row format are executed;
D. JSON file is transmitted, distribution command simultaneously activates Word generator;
E. it is inputted according to order line, parses JSON file content, verify the legitimacy and validity of JSON file format and content;
F. Word template directory path is obtained according to JSON file content, reads Word template directory file content;
G. it according to the Word template directory file content of reading, creates new Word document and fills document content;
H. word document is saved.
2. the method for generating Word document based on data configuration as described in claim 1, which is characterized in that
In step a, the Word template directory file includes: Word document structure category, document format catalogue, table format mesh
Record, document picture directory, document section reduce catalogue and document parameter list.
3. the method for generating Word document based on data configuration as claimed in claim 1 or 2, which is characterized in that
In step b, the JSON file of the specified format include: Word document storing path, Word document template directory path,
Word document picture directory path, Word text category path and Word reduce directory path.
4. the method for generating Word document based on data configuration as claimed in claim 1 or 2, which is characterized in that
Step f is specifically included:
1) file path is reduced according to document, obtains document and reduces set;
2) by recursive call, Word document tree-structure object is obtained;
3) by document format root path, the list of Word document format object is obtained;
4) by document picture root path, document tree object picture set is obtained;
5) by document text parameter path, document tree text parameter object set is obtained.
5. the method for generating Word document based on data configuration as claimed in claim 4, which is characterized in that
Step g is specifically included:
1) according to target Word document title in JSON, new Word document is created;
2) pass through incoming file catalogue structure objects and document picture object set, recursive generation Word document;
3) Word document format is set;
4) Word document text parameter is set;
5) Word document head and catalogue are set.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910468240.7A CN110187916B (en) | 2019-05-31 | 2019-05-31 | Method for generating Word document based on data configuration |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910468240.7A CN110187916B (en) | 2019-05-31 | 2019-05-31 | Method for generating Word document based on data configuration |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110187916A true CN110187916A (en) | 2019-08-30 |
CN110187916B CN110187916B (en) | 2022-09-02 |
Family
ID=67719266
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910468240.7A Active CN110187916B (en) | 2019-05-31 | 2019-05-31 | Method for generating Word document based on data configuration |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110187916B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110968997A (en) * | 2019-12-03 | 2020-04-07 | 广联达科技股份有限公司 | Strong controllable document generation method and device, storage medium and electronic equipment |
CN111159099A (en) * | 2019-11-15 | 2020-05-15 | 杭州数梦工场科技有限公司 | Online data generation method and device, electronic equipment and storage medium |
CN111399900A (en) * | 2020-03-10 | 2020-07-10 | 山东汇贸电子口岸有限公司 | API document automatic generation method and system based on python and regular expression |
CN113283228A (en) * | 2021-07-22 | 2021-08-20 | 北京关键科技股份有限公司 | Document generation method and device, electronic equipment and storage medium |
WO2022052407A1 (en) * | 2020-09-11 | 2022-03-17 | 苏州浪潮智能科技有限公司 | Device control method and system, electronic device, and storage medium |
Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102129364A (en) * | 2010-01-14 | 2011-07-20 | 中国电信股份有限公司 | Method for embedding widget toolbar in application program and rapid widget accessing method |
CN102637168A (en) * | 2012-03-19 | 2012-08-15 | 深圳市共进电子股份有限公司 | Method for realizing automatic language translation in graphical user interface |
US20140244692A1 (en) * | 2013-02-27 | 2014-08-28 | Cellco Partnership D/B/A Verizon Wireless | Converting xml to json with configurable output |
US9052864B1 (en) * | 2012-10-05 | 2015-06-09 | Marvell International Ltd. | Method and apparatus for processing a page description language document |
CN105975446A (en) * | 2016-04-19 | 2016-09-28 | 天津天大求实电力新技术股份有限公司 | Method and system for displaying word document content by modules in mobile phone terminal |
CN107016085A (en) * | 2017-03-31 | 2017-08-04 | 海通安恒科技有限公司 | A kind of computerized system verification management system |
CN108153721A (en) * | 2017-12-06 | 2018-06-12 | 中南林业科技大学 | A kind of automatic generation method in Word file embedded chart |
CN108171600A (en) * | 2018-01-19 | 2018-06-15 | 深圳前海大数金融服务有限公司 | Reference report analytic method, server and storage medium |
US20180232427A1 (en) * | 2017-02-13 | 2018-08-16 | Raytheon Company | Data structure endian conversion system |
CN109255114A (en) * | 2018-09-17 | 2019-01-22 | 四川长虹电器股份有限公司 | The system and method for Excel table and legend is generated based on data configuration |
CN109408783A (en) * | 2018-09-06 | 2019-03-01 | 广州城市信息研究所有限公司 | Electronic document online editing method and system |
-
2019
- 2019-05-31 CN CN201910468240.7A patent/CN110187916B/en active Active
Patent Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102129364A (en) * | 2010-01-14 | 2011-07-20 | 中国电信股份有限公司 | Method for embedding widget toolbar in application program and rapid widget accessing method |
CN102637168A (en) * | 2012-03-19 | 2012-08-15 | 深圳市共进电子股份有限公司 | Method for realizing automatic language translation in graphical user interface |
US9052864B1 (en) * | 2012-10-05 | 2015-06-09 | Marvell International Ltd. | Method and apparatus for processing a page description language document |
US20140244692A1 (en) * | 2013-02-27 | 2014-08-28 | Cellco Partnership D/B/A Verizon Wireless | Converting xml to json with configurable output |
CN105975446A (en) * | 2016-04-19 | 2016-09-28 | 天津天大求实电力新技术股份有限公司 | Method and system for displaying word document content by modules in mobile phone terminal |
US20180232427A1 (en) * | 2017-02-13 | 2018-08-16 | Raytheon Company | Data structure endian conversion system |
CN107016085A (en) * | 2017-03-31 | 2017-08-04 | 海通安恒科技有限公司 | A kind of computerized system verification management system |
CN108153721A (en) * | 2017-12-06 | 2018-06-12 | 中南林业科技大学 | A kind of automatic generation method in Word file embedded chart |
CN108171600A (en) * | 2018-01-19 | 2018-06-15 | 深圳前海大数金融服务有限公司 | Reference report analytic method, server and storage medium |
CN109408783A (en) * | 2018-09-06 | 2019-03-01 | 广州城市信息研究所有限公司 | Electronic document online editing method and system |
CN109255114A (en) * | 2018-09-17 | 2019-01-22 | 四川长虹电器股份有限公司 | The system and method for Excel table and legend is generated based on data configuration |
Non-Patent Citations (2)
Title |
---|
E. WAHYUDI 等: "Information Retrieval System for Searching JSON Files with Vector Space Model Method", 《2019 INTERNATIONAL CONFERENCE OF ARTIFICIAL INTELLIGENCE AND INFORMATION TECHNOLOGY (ICAIIT)》 * |
彭俊峰 等: "JavaEE的Web页面中操纵Word报表", 《电脑编程技巧与维护》 * |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111159099A (en) * | 2019-11-15 | 2020-05-15 | 杭州数梦工场科技有限公司 | Online data generation method and device, electronic equipment and storage medium |
CN111159099B (en) * | 2019-11-15 | 2023-08-22 | 杭州数梦工场科技有限公司 | Online data generation method and device, electronic equipment and storage medium |
CN110968997A (en) * | 2019-12-03 | 2020-04-07 | 广联达科技股份有限公司 | Strong controllable document generation method and device, storage medium and electronic equipment |
CN110968997B (en) * | 2019-12-03 | 2023-07-21 | 广联达科技股份有限公司 | Strong controllable document generation method and device, storage medium and electronic equipment |
CN111399900A (en) * | 2020-03-10 | 2020-07-10 | 山东汇贸电子口岸有限公司 | API document automatic generation method and system based on python and regular expression |
CN111399900B (en) * | 2020-03-10 | 2023-04-07 | 山东汇贸电子口岸有限公司 | API document automatic generation method and system based on python and regular expression |
WO2022052407A1 (en) * | 2020-09-11 | 2022-03-17 | 苏州浪潮智能科技有限公司 | Device control method and system, electronic device, and storage medium |
CN113283228A (en) * | 2021-07-22 | 2021-08-20 | 北京关键科技股份有限公司 | Document generation method and device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN110187916B (en) | 2022-09-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110187916A (en) | The method for generating Word document based on data configuration | |
CN107273117B (en) | Programming-friendly agile code automatic generation system | |
CN107291450B (en) | Programming-friendly agile code automatic generation method | |
CN110147240B (en) | Cloud storage-based application program installation method, system and storage medium | |
CN102591654B (en) | A kind of code generator based on SSH framework and method | |
US20190339947A1 (en) | Automatically generating code for application programming interfaces | |
WO2011127758A1 (en) | Method for manufacturing webpage, system, client and server thereof | |
CN108280023B (en) | Task execution method and device and server | |
CN102611576B (en) | Method and device for generating network management configuration model file | |
WO2020199423A1 (en) | Automated construction method and system for yang model configuration interface | |
CN109255114A (en) | The system and method for Excel table and legend is generated based on data configuration | |
JP6479184B2 (en) | Computer-executable model reverse engineering method and apparatus | |
CN105354237A (en) | Business data display method | |
CN106843878B (en) | A kind of model generating method and system | |
CN110008195A (en) | A kind of dynamic configuration html turns the method, apparatus and system of pdf | |
CN105554577B (en) | A kind of method, apparatus and smart television of smart television OTA upgrading | |
CN102455903B (en) | Method for generating user application interface | |
CN106502977B (en) | A kind of sheet disposal method and form system based on B/S framework | |
CN112711414A (en) | Form interface adaptation display method and device and storage medium | |
US20080189095A1 (en) | Method and tool for generating simulation case for ic device | |
CN115291869A (en) | Zero-code form generation method and system based on vue custom component | |
CN104503776A (en) | Method for rapidly packaging android application on APP development platform | |
KR100922526B1 (en) | Method and system of managing data quality through provisioning of metadata in the execution of business process | |
CN110471971A (en) | Data bank access method, equipment and storage medium | |
CN114895880A (en) | Code generation method and device and computer readable medium |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |