CN110187916B - Method for generating Word document based on data configuration - Google Patents

Method for generating Word document based on data configuration Download PDF

Info

Publication number
CN110187916B
CN110187916B CN201910468240.7A CN201910468240A CN110187916B CN 110187916 B CN110187916 B CN 110187916B CN 201910468240 A CN201910468240 A CN 201910468240A CN 110187916 B CN110187916 B CN 110187916B
Authority
CN
China
Prior art keywords
document
word
directory
format
path
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.)
Active
Application number
CN201910468240.7A
Other languages
Chinese (zh)
Other versions
CN110187916A (en
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.)
Sichuan Changhong Electric Co Ltd
Original Assignee
Sichuan Changhong Electric Co 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 Sichuan Changhong Electric Co Ltd filed Critical Sichuan Changhong Electric Co Ltd
Priority to CN201910468240.7A priority Critical patent/CN110187916B/en
Publication of CN110187916A publication Critical patent/CN110187916A/en
Application granted granted Critical
Publication of CN110187916B publication Critical patent/CN110187916B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation
    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE 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/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention relates to a Word document generation technology, discloses a method for generating a Word document based on data configuration, and solves the problems of high technical requirement, large code amount and low reusability in a mode of generating the Word document by directly accessing a bottom API in the traditional technology. The method comprises the following steps: a. configuring a Word template directory file; b. configuring a JSON file with a specified format; c. executing the command line, analyzing the parameters of the command line and verifying the format of the command line; d. transmitting a JSON file, distributing a command and activating a Word generator; e. analyzing the JSON file content according to the command line input, and verifying the legality and validity of the JSON file format and the content; f. obtaining a Word template directory path according to the JSON file content, and reading the Word template directory file content; g. creating a new Word document and filling the document content according to the read Word template directory file content; h. and saving the Word document. The invention is suitable for quickly generating the Word document.

Description

Method for generating Word document based on data configuration
Technical Field
The invention relates to a Word document generation technology, in particular to a method for generating a Word document based on data configuration.
Background
In the process of program or software development, the Word bottom API is called to realize the generation of the Word document. At present, most developers mainly access a bottom API to generate a Word document, the developers need to be familiar with the Word bottom API interface, including functions of Word document chapter number, outline level and content, text content and format, picture content and parameter replacement and the like, and need to compile complex codes to realize the functions, and the code quantity is large, and the logic is relatively complex.
Although the method of generating Word documents by directly accessing the underlying API can meet the requirements, the following disadvantages exist:
1) developers need to be familiar with API interfaces at the bottom layer of the Word, the logic is complex, and the technical requirement is high;
2) developers need to write a large amount of program codes, the process is complex, and the efficiency is low;
3) and a large amount of repeated codes exist, the reusability is low, and the maintainability is poor.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: the method for generating the Word document based on the data configuration is provided, and solves the problems of high technical requirement, large code amount and low reusability existing in the mode of generating the Word document by directly accessing the bottom API in the traditional technology.
The technical scheme adopted by the invention for solving the technical problems is as follows:
the method for generating the Word document based on the data configuration comprises the following steps:
a. configuring a Word template directory file;
b. configuring a JSON file with a specified format;
c. executing the command line, analyzing the parameters of the command line and verifying the format of the command line;
d. transmitting a JSON file, distributing a command and activating a Word generator;
e. analyzing the JSON file content according to the command line input, and verifying the legality and validity of the JSON file format and the content;
f. obtaining a Word template directory path according to the JSON file content, and reading the Word template directory file content;
g. creating a new Word document and filling the document content according to the read Word template directory file content;
h. and saving the word document.
As a further optimization, in step a, the Word template directory file includes: word document structure directory, document format directory, table format directory, document picture directory, document chapter clipping directory, and document parameter directory.
The scheme describes the detailed structure of the Word template directory file to be configured, and the Word template directory file can be called in a program or a project by adopting a command line mode through the configuration of the Word template directory file, thereby laying a foundation for the efficient generation of the Word document.
And c, as a further optimization, in the step b, the JSON file with the specified format comprises a Word document storage path, a Word document template directory path, a Word document picture directory path, a Word text directory path and a Word cutting directory path.
The detailed structure of JSON files in a specified format to be configured is described in the scheme, and the JSON files can be called in a program or a project in a command line mode through configuration of the JSON files, so that a foundation is laid for efficient generation of Word documents.
As a further optimization, step f specifically includes:
1) acquiring a document clipping set according to the document clipping file path;
2) obtaining a tree structure object of the Word document by recursive calling;
3) obtaining a Word document format object list through a document format root path;
4) acquiring a document tree picture object set through a document picture root path;
5) and acquiring a document tree text parameter object set through the document text parameter path.
In the scheme, the corresponding directory file contents are obtained through each directory path of the Word template, so that the Word document can be created simply and efficiently according to the contents and the corresponding contents are filled.
As a further optimization, step g specifically includes:
1) creating a new Word document according to the name of the target Word document in JSON;
2) recursively generating a Word document by transmitting a document directory structure object and a document picture object set;
3) setting a Word document format;
4) setting a Word document text parameter;
5) setting Word document head and catalog.
In the scheme, a new Word document is automatically created according to the name of the target Word document in JSON, and the content filling is automatically carried out on the newly created Word document according to the document directory structure object and the document picture object, so that the operation is simplified.
The invention has the beneficial effects that:
developers can access the Word template directory file and the JSON file in the specified format in a command line mode only by simply configuring the Word template directory file and the JSON file, so that the function of automatically generating the Word document is realized, the method can be widely applied to projects and programs needing to generate the Word document, the problems of high development difficulty, low code reusability, high cost and the like caused by directly using the API of the Word bottom layer are solved, and the efficiency of generating the Word document by the users is effectively improved.
Drawings
FIG. 1 is a flow chart of a method of generating a Word document based on data configuration in the present invention.
Detailed Description
The invention aims to provide a method for generating a Word document based on data configuration, which solves the problems of high technical requirement, large code amount and low reusability in the mode of generating the Word document by directly accessing a bottom API in the traditional technology. The core idea is as follows: configuring a Word template directory file and a JSON file with a specified format, and providing input information for an execution command line; after the command line analysis is executed, the data of the calling configuration is carried out according to the analyzed JSON parameter to create a Word document and fill corresponding contents, and finally, the generation of the Word document is simple, convenient and efficient.
As shown in FIG. 1, the method for generating Word document based on data configuration in the present invention comprises the following steps:
1. configuring a Word template directory file;
2. configuring a JSON file with a specified format;
3. executing the command line, analyzing the parameters of the command line and verifying the format of the command line;
4. transmitting a JSON file, distributing a command and activating a Word generator;
5. analyzing the JSON file content according to the command line input, and verifying the legality and validity of the JSON file format and the content;
6. obtaining a Word template directory path according to the JSON file content, and reading the Word template directory file content;
7. creating a new Word document and filling the document content according to the read Word template directory file content;
8. and saving the word document.
Example (b):
step one, configuring Word template directory files according to requirements, wherein the Word template directory files comprise related information such as a document structure directory, a document format directory, a table format directory, a document picture directory, a document chapter cutting directory, a document parameter directory and the like.
And step two, configuring JSON files with specified formats, wherein the JSON files comprise a Word document storage path, a Word document template directory path, a Word document picture directory path, a Word text directory path, a Word cutting directory path and the like.
Step three, executing the command line, and analyzing the command line data:
1) the program calls the line execution method of the order, the form is: "-t word-p json file path", such as: t word-p "e: \ project \ wordJson.
2) And executing the command line and judging whether the format of the command line is correct or not.
Step four, transmitting the JSON file, distributing the command, and calling the Word generator through reflection;
analyzing the JSON file content, and verifying whether the content is correct, wherein the verification of whether the JSON file format is correct and the verification of whether a path in the JSON file content is valid are included;
and step six, obtaining a template directory path according to the JSON file content, and reading the Word template directory file content.
1) Obtaining a document clipping set according to the document clipping file path
2) Through recursive invocation, a Word document tree structure object (an incoming parameter document structure root path, a parent node object, a current ID and an outline level) is obtained.
3) And acquiring a Word document format object list (acquiring each level of outline format and outline content format) through the document format root path.
4) And acquiring a document tree picture object set through the document picture root path.
5) And acquiring a document tree text parameter object set through the document text parameter path.
And step seven, obtaining a Word document path according to the JSON file content, creating a new Word document, and filling the document content.
1) And creating a new Word document according to the target Word document name in the JSON.
2) And recursively generating a Word document by transmitting a document directory structure object and a document picture object set.
3) Setting a Word document format.
4) Setting the text parameter of the Word document.
5) Setting Word document head and catalog.
And step eight, saving the Word document.

Claims (1)

1. The method for generating the Word document based on the data configuration is characterized by comprising the following steps of:
a. configuring a Word template directory file; the Word template directory file comprises: word document structure directory, document format directory, table format directory, document picture directory, document chapter cutting directory and document parameter directory;
b. configuring a JSON file with a specified format; the JSON file with the specified format comprises a Word document storage path, a Word document template directory path, a Word document picture directory path, a Word text directory path and a Word cutting directory path;
c. executing the command line, analyzing the parameters of the command line and verifying the format of the command line;
d. transmitting a JSON file, distributing a command and activating a Word generator;
e. analyzing the JSON file content according to the command line input, and verifying the legality and validity of the JSON file format and the content;
f. obtaining a Word template directory path according to the JSON file content, and reading the Word template directory file content;
g. creating a new Word document and filling the document content according to the read Word template directory file content;
h. saving the word document;
the step f specifically comprises the following steps:
1) acquiring a document clipping set according to the document clipping file path;
2) obtaining a tree structure object of the Word document by recursive calling;
3) obtaining a Word document format object list through a document format root path;
4) acquiring a document tree picture object set through a document picture root path;
5) acquiring a document tree text parameter object set through a document text parameter path;
the step g specifically comprises the following steps:
1) creating a new Word document according to the name of the target Word document in the JSON;
2) recursively generating a Word document by transmitting a document directory structure object and a document picture object set;
3) setting a Word document format;
4) setting a Word document text parameter;
5) setting Word document head and catalog.
CN201910468240.7A 2019-05-31 2019-05-31 Method for generating Word document based on data configuration Active CN110187916B (en)

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 CN110187916A (en) 2019-08-30
CN110187916B true 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)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111159099B (en) * 2019-11-15 2023-08-22 杭州数梦工场科技有限公司 Online data generation method and device, electronic equipment and storage medium
CN110968997B (en) * 2019-12-03 2023-07-21 广联达科技股份有限公司 Strong controllable document generation method and device, storage medium and electronic equipment
CN111399900B (en) * 2020-03-10 2023-04-07 山东汇贸电子口岸有限公司 API document automatic generation method and system based on python and regular expression
CN112114876B (en) * 2020-09-11 2023-01-10 苏州浪潮智能科技有限公司 Equipment control method, system, electronic equipment and storage medium
CN113283228A (en) * 2021-07-22 2021-08-20 北京关键科技股份有限公司 Document generation method and device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
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
US9052864B1 (en) * 2012-10-05 2015-06-09 Marvell International Ltd. Method and apparatus for processing a page description language document
CN107016085A (en) * 2017-03-31 2017-08-04 海通安恒科技有限公司 A kind of computerized system verification management system
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

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102637168A (en) * 2012-03-19 2012-08-15 深圳市共进电子股份有限公司 Method for realizing automatic language translation in graphical user interface
US9639631B2 (en) * 2013-02-27 2017-05-02 Cellco Partnership 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
CN108153721B (en) * 2017-12-06 2021-06-25 中南林业科技大学 Automatic generation method for embedding chart in Word file
CN109255114A (en) * 2018-09-17 2019-01-22 四川长虹电器股份有限公司 The system and method for Excel table and legend is generated based on data configuration

Patent Citations (5)

* Cited by examiner, † Cited by third party
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
US9052864B1 (en) * 2012-10-05 2015-06-09 Marvell International Ltd. Method and apparatus for processing a page description language document
CN107016085A (en) * 2017-03-31 2017-08-04 海通安恒科技有限公司 A kind of computerized system verification management system
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

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Information Retrieval System for Searching JSON Files with Vector Space Model Method;E. Wahyudi 等;《2019 International Conference of Artificial Intelligence and Information Technology (ICAIIT)》;20190315;260-265 *
JavaEE的Web页面中操纵Word报表;彭俊峰 等;《电脑编程技巧与维护》;20131014(第08期);86,91 *

Also Published As

Publication number Publication date
CN110187916A (en) 2019-08-30

Similar Documents

Publication Publication Date Title
CN110187916B (en) Method for generating Word document based on data configuration
US8250523B2 (en) Source code wrapper generation
CN104123227A (en) Method for automatically generating testing cases
CN104484216A (en) Method and device for generating service interface document and on-line test tool
CN101604241A (en) A kind of code generating method of embedded system
CN104407863A (en) Abstract control model programming device and method
CN110007924A (en) The automated construction method and system of YANG model configuration interface
CN109814865A (en) A kind of mobile application page generation method based on json data format
CN108763323B (en) Meteorological grid point file application method based on resource set and big data technology
CN104049974A (en) Dynamic control assembly method and system
CN108153919A (en) DBF data export platform and its deriving method
US20060047723A1 (en) Custom database system and method of building the same
CN106776779B (en) Method for generating entity file by JSON data based on Mac platform
US9244706B2 (en) Command line shell command generation based on schema
CN116627418B (en) Multi-level form interface visual generation method and device based on recursion algorithm
TWI629602B (en) Method for automatically generating website interactive program
US20100011018A1 (en) Custom database system and method of building the same
CN112711414A (en) Form interface adaptation display method and device and storage medium
CN116521181A (en) Script data processing method, device, equipment and medium based on game system
CN116400914A (en) Method for quickly constructing web application based on data model
CN115115787A (en) Method for converting two-dimensional drawing into 3D model based on DirectVR
CN115756433A (en) Code platform migration method and device, electronic equipment and readable storage medium
CN102779036B (en) For the Software tool of automatic technology
CN111506306A (en) Method and device for compiling Ansible script and electronic equipment
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