CN114239535A - Automatic Word document generation method and system based on webpage - Google Patents

Automatic Word document generation method and system based on webpage Download PDF

Info

Publication number
CN114239535A
CN114239535A CN202111583853.9A CN202111583853A CN114239535A CN 114239535 A CN114239535 A CN 114239535A CN 202111583853 A CN202111583853 A CN 202111583853A CN 114239535 A CN114239535 A CN 114239535A
Authority
CN
China
Prior art keywords
document
content
identifier
template
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
CN202111583853.9A
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.)
Sichuan XW Bank Co Ltd
Original Assignee
Sichuan XW Bank 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 XW Bank Co Ltd filed Critical Sichuan XW Bank Co Ltd
Priority to CN202111583853.9A priority Critical patent/CN114239535A/en
Publication of CN114239535A publication Critical patent/CN114239535A/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/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)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a method and a system for automatically generating a Word document based on a webpage, which are used for acquiring document contents, dividing the document contents into n module contents, and setting a corresponding first identifier for each module content; obtaining a Word template, wherein the Word module is divided into n area templates; randomly selecting an area template, setting a second identifier on the area template, matching the first identifier corresponding to the second identifier, reading module content corresponding to the first identifier, and filling the module content into the area template to obtain sub-document content; traversing n region templates in the Word template to obtain n sub-document contents, and outputting the n sub-document contents to generate a Word document; the method has the advantages that when different scene services are processed, the process of forming the template can be simplified, and the difference part of each scene can be shown.

Description

Automatic Word document generation method and system based on webpage
Technical Field
The invention relates to the technical field of document generation, in particular to a method and a system for automatically generating a Word document based on a webpage.
Background
In the prior art, Word is a Word processing system which is the most widely used in the world, a large number of Word reports need to be compiled every day, for example, different documents need to be compiled for different service scenes, so as to better look up the relevant contents of the service, or in the daily management work of the server operation, daily reports, weekly reports, monthly reports, quarterly reports and annual reports need to be compiled for the operation condition of each server.
In view of this, the present application is specifically made.
Disclosure of Invention
The invention aims to solve the technical problems that when a document with a single template is used for processing different scene services, only places with common contents of scenes can be shown, and the unique part of the scenes cannot be shown.
The invention is realized by the following technical scheme:
a method for automatically generating a Word document based on a webpage is applied to the webpage, and comprises the following steps:
step S1: acquiring document content, and dividing the document content into n module contents, wherein each module content is provided with a corresponding first identifier;
step S2: obtaining a Word template, wherein the Word module is divided into n area templates;
step S3: randomly selecting an area template, setting a second identifier on the area template, matching the first identifier corresponding to the second identifier, reading the module content corresponding to the first identifier, filling the module content into the area template to obtain sub-document content, wherein the second identifier is used for identifying the position of the area template into which the document content needs to be inserted;
step S4: and traversing n region templates in the Word template to obtain n sub-document contents, and outputting the n sub-document contents to generate the Word document.
Conventionally, when a document is constructed for a scene, a document designed in a business scene is generated based on a single template, but when the business scene is processed by adopting this method, in the document, the difference part of the scene can not be shown, and the document constructing method is complicated, the invention provides a method for automatically generating a Word document based on a webpage, by adopting the method of adding identifiers for different text area parts of the document, and carrying out corresponding matching through signals among the identifiers, through the matching among the identifiers, when the content is transmitted to the template in a data stream mode, a brand-new Word document is built, the process of forming the template can be simplified when different scene services are processed, and meanwhile, the difference part of each scene can be shown.
Preferably, the sub-step of step S3 includes:
arbitrarily selecting an area template, and setting a second identifier on the area template;
reading the content of the area template by adopting an IO input stream to obtain the IO stream;
analyzing the IO stream into file data, and acquiring the file data of a second identifier;
matching the corresponding first identifier based on the file data of the second identifier, and inserting the document content corresponding to the first identifier into the area template;
and adopting IO output stream to output to obtain the subdocument content.
Preferably, the Word templates are arranged by n region modules to form document templates with the same style in different scenes.
Preferably, the document content includes text content and attachment content, the text content is described in text in a paragraph form, and the attachment content includes picture file content and document file content.
Preferably, when the document content is text content, the text content is divided by paragraphs, and each paragraph is provided with the first identifier; when the document content is the attachment content, the first identifier is arranged on each attachment content.
Preferably, the accessory content and the first identifier are transmitted and stored in a key-value form.
The invention also provides a system for automatically generating the Word document based on the webpage, which comprises a document content acquisition module, a template acquisition module, a subdocument construction module and a document generation module,
the document content acquisition module is used for acquiring document contents and dividing the document contents into n module contents, and each module content is provided with a corresponding first identifier;
the template acquisition module is used for acquiring a Word template and dividing the Word template into n area templates;
the subdocument construction module is used for randomly selecting an area template, setting a second identifier on the area template, matching the first identifier corresponding to the second identifier, reading the module content corresponding to the first identifier, filling the module content into the area template to obtain subdocument content, wherein the second identifier is used for identifying the position of the area template into which the document content needs to be inserted;
and the document generating module is used for traversing n region templates in the Word template to obtain n sub-document contents, outputting the n sub-document contents and generating the Word document.
Preferably, the system further includes a first data storage module and a second data storage module, the first data storage module is configured to store the document content, and the second data storage module is configured to store the n region templates.
Preferably, in the first data storage module, when the document content is the attachment content, the attachment content and the first identifier are stored and recorded in a key-value form.
The invention also provides a computer-stored medium having a computer program stored thereon, which, when executed by a processor, implements a method as described above.
Compared with the prior art, the invention has the following advantages and beneficial effects:
1. according to the method and the system for automatically generating the Word document based on the webpage, the identifiers are added to different text area parts of the document, corresponding matching is carried out through signals among the identifiers, contents are transmitted to the template in a data flow mode through the matching among the identifiers, a brand-new Word document is constructed, the process of forming the template can be simplified when different scene services are processed, and meanwhile, the difference part of each scene can be shown;
2. according to the method and the system for automatically generating the Word document based on the webpage, provided by the embodiment of the invention, a plurality of personalized templates do not need to be arranged on the webpage, the templates are directly checked and inserted again, the templates are unified, and differentiation processing is carried out through attachments.
Drawings
In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and that for those skilled in the art, other related drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a schematic diagram of an automatic document generation method
FIG. 2 is a schematic diagram of an automatic document generation system
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail below with reference to examples and accompanying drawings, and the exemplary embodiments and descriptions thereof are only used for explaining the present invention and are not meant to limit the present invention.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. However, it will be apparent to one of ordinary skill in the art that: it is not necessary to employ these specific details to practice the present invention. In other instances, well-known structures, circuits, materials, or methods have not been described in detail so as not to obscure the present invention.
Throughout the specification, reference to "one embodiment," "an embodiment," "one example," or "an example" means: the particular features, structures, or characteristics described in connection with the embodiment or example are included in at least one embodiment of the invention. Thus, the appearances of the phrases "one embodiment," "an embodiment," "one example" or "an example" in various places throughout this specification are not necessarily all referring to the same embodiment or example. Furthermore, the particular features, structures, or characteristics may be combined in any suitable combination and/or sub-combination in one or more embodiments or examples. Further, those of ordinary skill in the art will appreciate that the illustrations provided herein are for illustrative purposes and are not necessarily drawn to scale. As used herein, the term "and/or" includes any and all combinations of one or more of the associated listed items.
In the description of the present invention, the terms "front", "rear", "left", "right", "upper", "lower", "vertical", "horizontal", "upper", "lower", "inner", "outer", etc. indicate orientations or positional relationships based on those shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed in a particular orientation, and be operated, and therefore, should not be construed as limiting the scope of the present invention.
Example one
The embodiment discloses a method for automatically generating a Word document based on a webpage, which is applied to the webpage as shown in fig. 1, and mainly aims to adopt templates of uniform types on the webpage under different scene services to realize the method for automatically generating the document, and the document constructed by the method can show the unique point of each scene on the same template of the same type, so that the document constructed by the embodiment can show the different part of each scene, and realize the personalized display of the scene content, and the method comprises the following steps:
step S1: acquiring document content, and dividing the document content into n module contents, wherein each module content is provided with a corresponding first identifier; in step S1, the obtained document content is a content that needs to be filled in a Word template, and the document content is divided by means of differentiation modules, each module content is provided with a first identifier, the set first identifier is used for matching with an area template in the Word template, and the document content can be transmitted to the corresponding area template by means of matching for filling.
In this embodiment, the document content includes text content and attachment content, the text content is described in text in a paragraph form, and the attachment content includes picture file content and document file content; when the document content is the text content, the text content is divided through paragraphs, each paragraph is provided with the first identifier, and when the document content is the text content, the document content is the public part content of the scene, namely, each scene relates to the content required for filling, such as the name of the scene, specific services and other information required for filling; when the document content is the attachment content, the first identifier is provided on each attachment content, and when the document content is the attachment, the document content is the differentiated content of the scene, including but not limited to pictures, document files, and other files formed in various forms.
In this embodiment, the accessory content and the first identifier are transmitted and stored in a key-value form.
Step S2: obtaining a Word template, wherein the Word module is divided into n area templates; in step S2, the obtained Word templates may be templates of various styles, but the obtained Word templates are a complete template composed of region templates divided into multiple regions, and when the Word templates are used to generate service requirements of different scenes, document templates of the same style are formed by arranging n region templates; therefore, by setting the template of the uniform type, personalized documents which need to be shown in different service scenes can be visually shown.
Step S3: randomly selecting an area template, setting a second identifier on the area template, matching the first identifier corresponding to the second identifier, reading the module content corresponding to the first identifier, filling the module content into the area template to obtain sub-document content, wherein the second identifier is used for identifying the position of the area template into which the document content needs to be inserted;
in step S3, the document content and the region module are matched with each other by parsing the second identifier and matching the file data, in this embodiment, the first identifier and the second identifier may be identifiers formed by letters such as "A, B, C, D …", and in the matching process, the identifiers of the same letter represent the document content corresponding to the letter and are filled in the region module corresponding to the letter.
In the present embodiment, the sub-step of step S3 includes:
arbitrarily selecting an area template, and setting a second identifier on the area template;
reading the content of the area template by adopting an IO input stream to obtain the IO stream;
the process is as follows:
reading a template stored in a database in a binary type, and acquiring a Byte array of bytes in the template. And converting the Byte groups into java analytically identifiable Document objects, and filtering and comparing the second identifier identified in the template in the Document objects to obtain the paragraph positions of the identifiers in the objects. And acquiring a corresponding Byte array by the accessory to be inserted in the same way, and after replacing the Byte of the corresponding identified position, formatting the content in a file format by the Document object and writing the content into the outputStream. And adopting IO output stream to output to obtain the subdocument content.
Step S4: traversing n region templates in the Word template to obtain n sub-document contents, outputting the n sub-document contents to generate a Word document, and in step S4, matching the document contents of each region template one by one to finally obtain the Word document in one scene.
By adopting the method for automatically generating the Word document based on the webpage provided by the embodiment, the identifiers are added to different text area parts of the document, the corresponding matching is carried out through the signals among the identifiers, and the brand new Word document is constructed by matching the identifiers and transmitting the content to the template in a data flow mode, so that the process of forming the template can be simplified when different scene services are processed, and the difference part of each scene can be displayed.
Example two
The embodiment discloses a system for automatically generating a Word document based on a webpage, as shown in FIG. 2, the embodiment is a method for automatically generating a document, which comprises a document content acquisition module, a template acquisition module, a sub-document construction module and a document generation module,
the document content acquisition module is used for acquiring document contents and dividing the document contents into n module contents, and each module content is provided with a corresponding first identifier;
the template acquisition module is used for acquiring a Word template and dividing the Word template into n area templates;
the subdocument construction module is used for randomly selecting an area template, setting a second identifier on the area template, matching the first identifier corresponding to the second identifier, reading the module content corresponding to the first identifier, filling the module content into the area template to obtain subdocument content, wherein the second identifier is used for identifying the position of the area template into which the document content needs to be inserted;
and the document generating module is used for traversing n region templates in the Word template to obtain n sub-document contents, outputting the n sub-document contents and generating the Word document.
In this embodiment, the system further includes a first data storage module and a second data storage module, where the first data storage module is configured to store the document content, the second data storage module is configured to store n region templates, and the first data storage module and the second data storage module are mainly configured to store and record related data modules.
In the first data storage module, when the document content is the attachment content, the attachment content and the first identifier are stored and recorded in a key-value form.
EXAMPLE III
The embodiment discloses a computer storage medium, which is stored with a computer program, and is characterized in that when the computer program is executed by a processor, the automatic generation method of the Word document is realized.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are merely exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (10)

1. A method for automatically generating a Word document based on a webpage is characterized in that the method is applied to the webpage, and the method comprises the following steps:
step S1: acquiring document content, and dividing the document content into n module contents, wherein each module content is provided with a corresponding first identifier;
step S2: obtaining a Word template, wherein the Word module is divided into n area templates;
step S3: randomly selecting an area template, setting a second identifier on the area template, matching the first identifier corresponding to the second identifier, reading the module content corresponding to the first identifier, filling the module content into the area template to obtain sub-document content, wherein the second identifier is used for identifying the position of the area template into which the document content needs to be inserted;
step S4: and traversing n region templates in the Word template to obtain n sub-document contents, and outputting the n sub-document contents to generate the Word document.
2. A method for automatically generating a Word document based on a web page as claimed in claim 1, wherein the sub-step of the step S3 includes:
arbitrarily selecting an area template, and setting a second identifier on the area template;
reading the content of the area template by adopting an IO input stream to obtain the IO stream;
analyzing the IO stream into file data, and acquiring the file data of a second identifier;
matching the corresponding first identifier based on the file data of the second identifier, and inserting the document content corresponding to the first identifier into the area template;
and adopting IO output stream to output to obtain the subdocument content.
3. A Word document automatic generation method based on web page as claimed in claim 2, characterized in that the Word template is a document template with the same style arranged by n region modules in different scenes.
4. A method for automatically generating a Word document based on a web page as recited in claim 2, wherein the document content includes text content and attachment content, the text content is described in words in paragraph form, and the attachment content includes picture file content and document file content.
5. A method for automatically generating a Word document based on a webpage as claimed in claim 4, wherein when the document content is text content, the text content is divided by paragraphs, and each paragraph is provided with the first identifier; when the document content is the attachment content, the first identifier is arranged on each attachment content.
6. A method for automatically generating a Word document based on a web page as recited in claim 5, wherein the attachment content and the first identifier are transmitted and stored in a key-value form.
7. A Word document automatic generation system based on webpage is characterized by comprising a document content acquisition module, a template acquisition module, a subdocument construction module and a document generation module,
the document content acquisition module is used for acquiring document contents and dividing the document contents into n module contents, and each module content is provided with a corresponding first identifier;
the template acquisition module is used for acquiring a Word template and dividing the Word template into n area templates;
the subdocument construction module is used for randomly selecting an area template, setting a second identifier on the area template, matching the first identifier corresponding to the second identifier, reading the module content corresponding to the first identifier, filling the module content into the area template to obtain subdocument content, wherein the second identifier is used for identifying the position of the area template into which the document content needs to be inserted;
and the document generating module is used for traversing n region templates in the Word template to obtain n sub-document contents, outputting the n sub-document contents and generating the Word document.
8. A system for automatically generating a Word document based on a web page as recited in claim 7, further comprising a first data storage module and a second data storage module, wherein said first data storage module is used for storing the document contents, and said second data storage module is used for storing n region templates.
9. A system for automatically generating a Word document based on a web page as recited in claim 8, wherein in the first data storage module, when the document content is an attachment content, the attachment content and the first identifier are stored and recorded in a key-value form.
10. A computer-stored medium on which a computer program is stored, which computer program, when being executed by a processor, carries out the method according to any one of claims 1 to 6.
CN202111583853.9A 2021-12-22 2021-12-22 Automatic Word document generation method and system based on webpage Pending CN114239535A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111583853.9A CN114239535A (en) 2021-12-22 2021-12-22 Automatic Word document generation method and system based on webpage

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111583853.9A CN114239535A (en) 2021-12-22 2021-12-22 Automatic Word document generation method and system based on webpage

Publications (1)

Publication Number Publication Date
CN114239535A true CN114239535A (en) 2022-03-25

Family

ID=80761609

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111583853.9A Pending CN114239535A (en) 2021-12-22 2021-12-22 Automatic Word document generation method and system based on webpage

Country Status (1)

Country Link
CN (1) CN114239535A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114968447A (en) * 2022-03-30 2022-08-30 中国人寿保险股份有限公司 Online webpage generation and management method and related equipment
CN115146606A (en) * 2022-08-02 2022-10-04 上海三力信息科技有限公司 Method, system, equipment and storage medium for creating and managing enrollment information

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114968447A (en) * 2022-03-30 2022-08-30 中国人寿保险股份有限公司 Online webpage generation and management method and related equipment
CN115146606A (en) * 2022-08-02 2022-10-04 上海三力信息科技有限公司 Method, system, equipment and storage medium for creating and managing enrollment information

Similar Documents

Publication Publication Date Title
CN109299446B (en) Report generation method and device
CA2669479C (en) Generating end-user presentations from structured data
CN101025738B (en) Template-free dynamic website generating method
CN102314460B (en) Data analysis method and system and servers
CN114239535A (en) Automatic Word document generation method and system based on webpage
CN107092625B (en) Data configuration method, data processing method and device
US7720885B2 (en) Generating a word-processing document from database content
CN103123631B (en) The generation of official documents and correspondence, the methods of exhibiting of webpage official documents and correspondence, device and Website server
CN111126019B (en) Report generation method and device based on mode customization and electronic equipment
CN103617047A (en) Method, device and processor for developing business processes
CN105095168A (en) Automatic generation method and device for contract files
US7720814B2 (en) Repopulating a database with document content
CN103530407A (en) Method and device for generating rich text document
US20140358974A1 (en) System and method for integral management of information for end users
CN113609820A (en) Method, device and equipment for generating word file based on extensible markup language file
US20070061349A1 (en) Hierarchically describing shapes
CN113761859B (en) Electronic report definition method and device and electronic equipment
CN104536998A (en) Data import method and device
CN116301813B (en) Low-code platform development method and system
CN112800371A (en) Method and device for processing spreadsheet data in web page
CN100407204C (en) Method for labeling computer resource and system therefor
CN106528516A (en) Method for establishing analysis report
CN111352917B (en) Information input method and device, electronic equipment and storage medium
CN111125063B (en) Method and device for rapidly checking data migration among clusters
CN103617193A (en) Cookie information processing method and cookie information processing browser

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