Report document automation method easy for secondary development

文档序号:1127732 发布日期:2020-10-02 浏览:20次 中文

阅读说明:本技术 一种易于二次开发的报告文档自动化方法 (Report document automation method easy for secondary development ) 是由 李浩然 王季孟 张长志 周连升 甘智勇 倪玮晨 赵毅 *** 王建 于 2020-06-04 设计创作,主要内容包括:本发明涉及一种易于二次开发的报告文档自动化方法,其技术特点是:在报告文档中使用占位符替换需要根据试验数据更新的文本,并根据如对算法将试验数据按照报告文档中出现的顺序入队生成队列数据,使用COM模型的函数对报告文档的占位符进行检索,当检索到占位符时,并将队列数据中对应的数据替换该占位符,循环至报告文档的末尾,输出更新数据后的报告文档。本发明实现了报告文档简单便捷的自动化生成功能,并保留了报告文档现有的格式,具有学习成本低,开发效率高的优势,并能够节约工作人员制作报告文档的时间。(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.)

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.

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.

7页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:文本相似度确定方法、装置、设备和介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!