CN111737953A - Report document automation method easy for secondary development - Google Patents

Report document automation method easy for secondary development Download PDF

Info

Publication number
CN111737953A
CN111737953A CN202010498420.2A CN202010498420A CN111737953A CN 111737953 A CN111737953 A CN 111737953A CN 202010498420 A CN202010498420 A CN 202010498420A CN 111737953 A CN111737953 A CN 111737953A
Authority
CN
China
Prior art keywords
report document
data
report
placeholder
word
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
CN202010498420.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.)
State Grid Corp of China SGCC
State Grid Tianjin Electric Power Co Ltd
Electric Power Research Institute of State Grid Tianjin Electric Power Co Ltd
Original Assignee
State Grid Corp of China SGCC
State Grid Tianjin Electric Power Co Ltd
Electric Power Research Institute of State Grid Tianjin Electric Power 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 State Grid Corp of China SGCC, State Grid Tianjin Electric Power Co Ltd, Electric Power Research Institute of State Grid Tianjin Electric Power Co Ltd filed Critical State Grid Corp of China SGCC
Priority to CN202010498420.2A priority Critical patent/CN111737953A/en
Publication of CN111737953A publication Critical patent/CN111737953A/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
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The invention relates to a report document automation method easy for secondary development, which is technically characterized in that: replacing a text which needs to be updated according to test data by using a placeholder in a report document, enqueuing the test data according to the sequence appearing in the report document according to an algorithm to generate queue data, retrieving the placeholder of the report document by using a function of a COM (component object model) model, replacing the placeholder by corresponding data in the queue data when the placeholder is retrieved, circulating to the tail of the report document, and outputting the report document after the data is updated. The invention realizes the automatic generation function of the report document, reserves the existing format of the report document, has the advantages of low learning cost and high development efficiency, and can save the time for workers to make the report document.

Description

Report document automation method easy for secondary development
Technical Field
The invention belongs to the technical field of information, and particularly relates to a report document automation method easy for secondary development.
Background
Word is the most widely used Word processing system in the world, and all industries have a large amount of Word reports to be compiled every day, and for most reports, the format templates of the reports are the same, and only the data elements are different, and the data elements comprise characters, tables, pictures, charts, various mathematical chemical formulas and the like, and besides the elements, the Word processing system also has control over styles, such as fonts, Word sizes, colors, segment front distances, segment back distances, Word intervals, line intervals, project symbols, indents, page headers and page footers, borders, shading and the like. For a report, if the typesetting process is operated manually, the workload is huge and tedious, the time consumption is high, the efficiency is low, the accuracy is relatively low, and the typesetting style error is easy to occur in the operation process.
At present, the following schemes are mainly used for report document automation:
firstly, the format, the style, the static element, the dynamic data and the like of the report are all solidified in the program code, the mode is non-visual, the static element and the dynamic data are completely mixed together and are all composed of the code, the realization is not flexible enough, the expansion is difficult, and the maintenance cost is very high.
And secondly, generating a webpage report by using a dynamic webpage technology, namely reserving a corresponding position definition variable in the Html tag in advance, and then replacing the position definition variable in the operation process. The modes are all tools developed and used in professional levels, and the typesetting effect is not professional enough, such as paging of reports, header and footer control, generation of report catalogues, influence of contents in variables in reports on paging and the like are difficult to finely control, page number errors, header and footer are often generated in printing, the corresponding positions are not located in the printing process, and the flexibility and the typesetting specialty are poor.
In summary, in the prior art, the automatic generation method of the report has the problems of insufficient flexibility in implementation, poor typesetting effect and single report format due to the mixing of the template and the data, and the report automation cannot be quickly and effectively implemented based on the existing report document.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provides a report document automation method easy for secondary development, which can quickly and effectively realize the report automation function.
The technical problem to be solved by the invention is realized by adopting the following technical scheme:
a report document automation method easy for secondary development comprises the following steps:
step 1, according to the requirement of a report document, replacing all texts needing to be updated according to test data by using uniform placeholders for the existing report document in Word;
step 2, calling a wind 32.client. generatian. EnsureDispatch () function in the COM model to generate a word.application static proxy object;
step 3, opening a report document template, calling a word.application.documents.open function in the COM model, inputting a report document template storage path, and generating a report document template object;
step 4, adopting a queue data model, enqueuing the test data according to the sequence appearing in the report document according to an enqueuing algorithm, and generating queue data;
step 5, calling a word.application.documents.selection.find () function in the COM model, and retrieving placeholders from the starting position of the report document;
step 6, when the placeholder is searched, extracting corresponding experimental data from the queue data, and sorting the output format of the data;
step 7, calling a word.application.documents.selection.typetext () function in the COM model, and replacing the searched placeholder with corresponding data in the queue data;
and 8, continuously retrieving the placeholders from the retrieved position of the placeholder backwards, repeating the steps 5 to 7 until the report document is retrieved, and outputting the report document after the data is updated.
Furthermore, the placeholder in step 1 consists of a succession of bit words.
Moreover, the placeholders composed of consecutive digits of characters are not repeated with any string of the same length within the report document, and the respective placeholders are guaranteed to be consistent.
And, the enqueuing algorithm in the step 4 is designed according to the writing logic in the report document template.
The invention has the advantages and positive effects that:
the method comprises the steps of replacing texts needing to be updated according to test data with placeholders in a report document, enqueuing the test data according to the sequence appearing in the report document to generate queue data, replacing the placeholders in the report document with data in the corresponding queue data by using a function of a COM model, and outputting the report document after the data is updated. The report document is automatically generated simply and conveniently, the existing format of the report document is reserved, the method has the advantages of low learning cost and high development efficiency, and the time for workers to make the report document can be saved.
Drawings
FIG. 1 is a block flow diagram of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings.
An automated method of reporting documentation that is easy to redevelop, as shown in fig. 1, comprising the steps of:
step 1, making a report document template, editing the existing report document by using Word, and replacing all texts in the existing report document, which need to be updated according to test data, by using uniform placeholders.
In this step, the placeholders are composed of consecutive bit characters and are kept consistent, wherein the content of the placeholder is specified by the developer. Also, placeholders need to be guaranteed not to be duplicated with any string of the same length within the report document, and whether containing uncommon words or special characters. In the tests, the length of the placeholder should be 3 to 6 characters in order to guarantee the efficiency of the regular matching algorithm.
And 2, calling a wind 32.client. generatian cache. EnsureDispatch () function in the COM model to generate a word.
In this step, the COM is an abbreviation of ComponentObjectModel, and is a platform-independent, distributed, object-oriented application model for creating interactive Win32 program components. COM is the basic technology of Microsoft compound document OLE and Internet component ActiveX technology. The COM object is created through various programming languages, and the COM object can be used for realizing control on the bottom layer of the Word program, so that a test report script is compiled, and the automatic compiling of the existing report document is realized.
And step 3, opening a report document template, calling a word.application.documents.open function in the COM model, inputting a report document template storage path, and generating a report document template object.
And 4, adopting a queue data model, enqueuing the test data according to the sequence appearing in the report document according to an enqueuing algorithm, and generating queue data.
In this step, the enqueuing algorithm is designed according to the writing logic in the report document template. For example: for data enqueuing in a Word table, defining a row enqueuing function, and enqueuing all cells in the same row from left to right in sequence; defining a table enqueue function, and repeatedly calling the row enqueue function in sequence to enable data of each row of the same table to be enqueued from top to bottom in sequence; and finally, calling the table enqueuing functions in the report document enqueuing function in sequence to enqueue each table data in the report document from top to bottom.
And 5, calling a word.application.documents.selection.find () function in the COM model, and retrieving the placeholder from the starting position of the report document.
And 6, when the placeholders are retrieved, extracting corresponding experimental data from the queue data, and sorting the output format of the data.
And 7, calling a word.application.documents.selection.TypeText () function in the COM model, and replacing the searched placeholder with corresponding data in the queue data.
And 8, continuously retrieving the placeholders from the retrieved position of the placeholder backwards, repeating the steps 5 to 7 until the report document is retrieved, and outputting the report document after the data is updated.
According to the report document automation method easy for secondary development, the report document of a certain detection data is tested,
wherein, the content of the report document is as follows:
year, month, day, and load, the schedule sets the AGC command to MW, the load change rate to ___ MW/min, the actual load response time to ___ s, the actual load of the ___ photovoltaic power plant changes to ___ MW, and the actual load change rate is ___ MW/min. The maximum dynamic deviation during the period is ___ MW, and the maximum static deviation is ___ MW.
Setting the placeholder as < + >, replacing all texts in the report document which need to be updated according to the test data with the placeholder, and generating a report document template with the placeholder as follows:
year < + > month < + > day < + > MW, load is < + > MW, the AGC command is set to < + > MW by scheduling, the load change rate is set to < + > MW/min, the actual load response time is < + > s, and the actual load change rate is < + > MW/min until the actual load of the < + > photovoltaic power station is changed to < + > MW. The maximum dynamic deviation during the period is < + > MW, and the maximum static deviation is < + > MW.
And enqueuing the test data according to an enqueuing algorithm according to the sequence appearing in the report document, wherein the generated queue data is as follows:
2019,8,21,12:07:09,3.20,28.00,4.00,1,12,11,41,26.16,5.01,0.91,0.46
after the method is finished, the output report document is as follows:
8, 21 and 8 months in 2019, 12:07:09, the load is 3.20MW, the AGC command is set to 28.00MW in scheduling, the load change rate is set to 4.00MW/min, the actual load response time is 1s, the actual load of the photovoltaic power station is changed to 26.16MW from 12:11:41, and the actual load change rate is 5.01 MW/min. The maximum dynamic deviation during the period is 0.91MW and the maximum static deviation is 0.46 MW.
And all the placeholders are replaced by corresponding test data, the format of the report document is unchanged, and the report document with updated data is accurately generated.
By testing the report document of the certain detection data, the method can generate the report document template after data updating, realize the function of simply and conveniently realizing the automatic generation of the report document, keep the existing format of the report document, have the advantages of low learning cost and high development efficiency, and can save the time for workers to make the report document.
It should be emphasized that the embodiments described herein are illustrative rather than restrictive, and thus the present invention is not limited to the embodiments described in the detailed description, but also includes other embodiments that can be derived from the technical solutions of the present invention by those skilled in the art.

Claims (4)

1. An automated method of reporting documentation that is easy to redevelop, comprising the steps of:
step 1, according to the requirement of a report document, replacing all texts needing to be updated according to test data by using uniform placeholders for the existing report document in Word;
step 2, calling a wind 32.client. generatian. EnsureDispatch () function in the COM model to generate a word.application static proxy object;
step 3, opening a report document template, calling a word.application.documents.open function in the COM model, inputting a report document template storage path, and generating a report document template object;
step 4, adopting a queue data model, enqueuing the test data according to the sequence appearing in the report document according to an enqueuing algorithm, and generating queue data;
step 5, calling a word.application.documents.selection.find () function in the COM model, and retrieving placeholders from the starting position of the report document;
step 6, when the placeholder is searched, extracting corresponding experimental data from the queue data, and sorting the output format of the data;
step 7, calling a word.application.documents.selection.typetext () function in the COM model, and replacing the searched placeholder with corresponding data in the queue data;
and 8, continuously retrieving the placeholders from the retrieved position of the placeholder backwards, repeating the steps 5 to 7 until the report document is retrieved, and outputting the report document after the data is updated.
2. The automated method for report documentation easy for secondary development of claim 1 wherein: the placeholder in said step 1 consists of a succession of bit characters.
3. The automated method for report documentation easy for secondary development of claim 2 wherein: the placeholders composed of consecutive several-digit characters are not repeated with any string of the same length in the report document, and the placeholders are guaranteed to be consistent.
4. The automated method for report documentation easy for secondary development of claim 1 wherein: the enqueuing algorithm in the step 4 is realized according to the writing logic in the report document template.
CN202010498420.2A 2020-06-04 2020-06-04 Report document automation method easy for secondary development Pending CN111737953A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010498420.2A CN111737953A (en) 2020-06-04 2020-06-04 Report document automation method easy for secondary development

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010498420.2A CN111737953A (en) 2020-06-04 2020-06-04 Report document automation method easy for secondary development

Publications (1)

Publication Number Publication Date
CN111737953A true CN111737953A (en) 2020-10-02

Family

ID=72648327

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010498420.2A Pending CN111737953A (en) 2020-06-04 2020-06-04 Report document automation method easy for secondary development

Country Status (1)

Country Link
CN (1) CN111737953A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100313119A1 (en) * 2009-06-05 2010-12-09 Microsoft Corporation In-line dynamic text with variable formatting
US20150199346A1 (en) * 2014-01-15 2015-07-16 Software Ag Hierarchical database report generation with automated query generation for placeholders
CN109657215A (en) * 2018-09-27 2019-04-19 深圳壹账通智能科技有限公司 Document structure tree method, equipment, storage medium and device based on template
CN110991156A (en) * 2019-11-20 2020-04-10 哈尔滨工程大学 Automatic report generation method based on ship numerical value virtual test
CN111145855A (en) * 2019-12-30 2020-05-12 南京求臻基因科技有限公司 Automatic generation method and system for clinical PDF report

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100313119A1 (en) * 2009-06-05 2010-12-09 Microsoft Corporation In-line dynamic text with variable formatting
US20150199346A1 (en) * 2014-01-15 2015-07-16 Software Ag Hierarchical database report generation with automated query generation for placeholders
CN109657215A (en) * 2018-09-27 2019-04-19 深圳壹账通智能科技有限公司 Document structure tree method, equipment, storage medium and device based on template
CN110991156A (en) * 2019-11-20 2020-04-10 哈尔滨工程大学 Automatic report generation method based on ship numerical value virtual test
CN111145855A (en) * 2019-12-30 2020-05-12 南京求臻基因科技有限公司 Automatic generation method and system for clinical PDF report

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
"竹先森゜: "Python使用win32com模块对word文件进行操作", 《博客园》 *
仝营: "Word修订模式批量查找替换的实现", 《电脑编程技巧与维护》 *
常涛等: "数据库数据导Word文档的方法浅析", 《电脑编程技巧与维护》 *
王川等: "《中文版office 2000 VBA一册通》", 31 January 2000 *
饶期捷等: "面向办公辅助应用的Word文档名自动生成技术", 《信息与电脑(理论版)》 *

Similar Documents

Publication Publication Date Title
CN106844307B (en) System and method for converting Excel into Word based on mark
CN109857670B (en) Test report automatic generation method based on universal template
CN107783949A (en) A kind for the treatment of method and apparatus of PPT documents
CN109683881B (en) Code format adjusting method and device
CN103559184A (en) Form page display method and device
CN104503955A (en) Method for generating personalized excel form
CN111737953A (en) Report document automation method easy for secondary development
CN111159979A (en) Method and program for generating pdf document by integrating dynamic data
CN110968999A (en) Annotating method and system for automatically realizing fine granularity and diversification of docx file
CN113569543B (en) Implementation method of nuclear power engineering automatic report generation technology
CN112905450B (en) Automatic chip register development system based on template variable replacement
CN115841095A (en) Document establishing method, system, medium and equipment
CN116956838A (en) Project determining method and device for engineering quantity list
CN114911466A (en) Data quality control system of acquisition terminal
CN110991156B (en) Automatic report generation method based on ship numerical virtual test
CN111209726A (en) Intelligent report generation system
CN115114689B (en) Geometric border marking method, device, electronic equipment and readable storage medium
Sudarsan et al. Industrial Control Systems-Legacy System Documentation and Augmentation
CN111459904B (en) TPM document automatic management system and method
CN110059424A (en) Steel structure module Machining information extraction based on TEKLA software
Xu Translation and Typesetting for Publishers
Trubnikov et al. Implementation of a helper program for comics creation using text processing methodS
CN116226035A (en) Method and device for converting OpenXML document into Web form
CN109145266B (en) Method for quickly generating dynamic PDF (Portable document Format) file from picture
CN114611467A (en) File editing and data structuring method based on B/S architecture

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20201002

RJ01 Rejection of invention patent application after publication