CN113408244B - Method, device, equipment and medium for generating Word document by Java application - Google Patents

Method, device, equipment and medium for generating Word document by Java application Download PDF

Info

Publication number
CN113408244B
CN113408244B CN202110691923.6A CN202110691923A CN113408244B CN 113408244 B CN113408244 B CN 113408244B CN 202110691923 A CN202110691923 A CN 202110691923A CN 113408244 B CN113408244 B CN 113408244B
Authority
CN
China
Prior art keywords
data
placeholder
word
freemarker
target
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
CN202110691923.6A
Other languages
Chinese (zh)
Other versions
CN113408244A (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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202110691923.6A priority Critical patent/CN113408244B/en
Publication of CN113408244A publication Critical patent/CN113408244A/en
Application granted granted Critical
Publication of CN113408244B publication Critical patent/CN113408244B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/116Details of conversion of file system types or formats
    • 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
    • G06F40/126Character encoding
    • 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

Landscapes

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

Abstract

The application relates to the technical field of data processing, and discloses a method, a device, equipment and a medium for generating Word documents by Java application, wherein the method comprises the following steps: determining a plain text placeholder set and a non-plain text placeholder set according to the target FreeMarker template identification set; according to a service database, respectively and sequentially carrying out service data searching and KV data pair assembling aiming at each placeholder in a plain text placeholder set to obtain a first KV data pair set; according to the picture database, picture identification searching and KV data pair assembling are sequentially carried out on each placeholder in the non-plain text placeholder set to obtain a second KV data pair set; and obtaining a target Word document based on the FreeMarker framework according to the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set. There is no need to encode and adjust the style in large amounts for specific content.

Description

Method, device, equipment and medium for generating Word document by Java application
Technical Field
The application relates to the technical field of data processing, in particular to a method, a device, equipment and a medium for generating Word documents by Java application.
Background
Java applications developed using Java (object oriented programming language) technology are widely used, so that the need for generating Word documents from web pages opened by Java applications is increasing. Because Microsoft does not have an interface for opening and writing a document in a Microsoft Office (Office software suite) format to Java, apache POI (open source function library of Apache software foundation) is adopted to generate a Word (Office software) document according to a webpage opened by Java application in the traditional way, but the mode only supports the generation of a simple Word document, when the Word document to be generated is complex, a large number of encoding and debugging patterns are needed because of containing various types of charts and pictures, and when the patterns are complex, the patterns are difficult to debug to the patterns meeting the requirements.
Disclosure of Invention
The application mainly aims to provide a method, a device, equipment and a medium for generating a Word document by a Java application, and aims to solve the technical problems that in the prior art, the Word document is generated by adopting Apache POI according to a webpage opened by the Java application, a large number of coding and debugging patterns are required for the relatively complex Word document, and the debugging patterns are difficult.
In order to achieve the above object, the present application provides a method for generating Word documents by using a Java application, where the method is applicable to the Java application, and the Java application integrates a FreeMarker framework, and the method includes:
Acquiring a Word document generation request, wherein the Word document generation request carries a target FreeMarker template identification set and target position configuration data;
acquiring placeholders from templates corresponding to the target FreeMarker template identification set to obtain a placeholder set to be processed;
dividing the placeholders in the placeholder set to be processed according to the types of the placeholders to obtain a plain text placeholder set and a non-plain text placeholder set;
acquiring a service database, and respectively carrying out service data searching and KV data pair assembling in sequence for each placeholder in the plain text placeholder set according to the service database to obtain a first KV data pair set;
acquiring a picture database, and respectively carrying out picture identification searching and KV data pair assembling in sequence for each placeholder in the non-plain text placeholder set according to the picture database to obtain a second KV data pair set;
and generating Word documents according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set based on the FreeMarker frame to obtain target Word documents.
Further, before the step of obtaining the Word document generation request, the method includes:
acquiring a template generation request;
responding to the template generation request, acquiring a FreeMarker template identifier to be added, word frame data to be added, word style data to be added, a placeholder set to be added and a template object position data set to be processed, wherein the Word frame data to be added is Word frame data obtained based on Html, and the Word style data to be added is Word style data obtained based on CSS;
generating a static page according to the FreeMarker template identifier to be added, the Word frame data to be added, the Word style data to be added, the placeholder set to be added and the template object position data set to be processed, so as to obtain a static page to be converted;
performing flt file format conversion on the static page to be converted to obtain a FreeMarkr template to be stored;
and updating the FreeMark template library according to the FreeMark template to be stored.
Further, the step of obtaining the picture database includes:
obtaining a chart placeholder from the non-plain text placeholder set to obtain a chart placeholder set;
According to the service database, respectively carrying out chart generation and picture conversion in sequence for each chart placeholder in the chart placeholder set to obtain a picture set to be stored;
and acquiring the picture database, and updating the picture database according to the picture set to be stored.
Further, the step of generating a Word document based on the FreeMarker framework according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set to obtain a target Word document includes:
based on the FreeMarker frame, acquiring a FreeMarker template library, and constructing a document frame according to the FreeMarker template library, the target FreeMarker template identification set and the target position configuration data to obtain a flt file to be replaced;
and generating Word documents according to the flt file to be replaced, the picture database, the first KV data pair set and the second KV data pair set based on the FreeMarker framework, and obtaining the target Word documents.
Further, the step of generating a Word document based on the FreeMarker framework according to the flt file to be replaced, the picture database, the first KV data pair set and the second KV data pair set to obtain the target Word document includes:
Based on the FreeMark frame, replacing the placeholders in the flt file to be replaced according to the picture database, the first KV data pair set and the second KV data pair set to obtain the flt file to be converted;
and converting the format of the Word document to the flt file to be converted based on the FreeMarker framework to obtain the target Word document.
Further, a Word-to-PDF plug-in is integrated in the Java application, wherein the Word-to-PDF plug-in is a plug-in obtained based on OpenOoffice;
the step of generating Word documents based on the FreeMarker framework according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set to obtain target Word documents further comprises the following steps:
acquiring a PDF conversion request;
responding to the PDF conversion request, and sending the target Word document to the Word PDF conversion plug-in;
and based on the Word-to-PDF plug-in, performing PDF file format conversion on the target Word document to obtain the target PDF document.
Further, the step of performing PDF file format conversion on the target Word document based on the Word-to-PDF plug-in to obtain the target PDF document includes:
Acquiring a preset storage address;
performing PDF file format conversion on the target Word document by adopting an Office document converter of the Word-to-PDF plug-in unit to obtain the target PDF document;
and storing the target PDF document into a folder corresponding to the preset storage address.
The application also provides a device for generating the Word document by the Java application, which is suitable for the Java application, integrates a FreeMarker framework in the Java application, and comprises the following steps:
the request acquisition module is used for acquiring a Word document generation request, wherein the Word document generation request carries a target FreeMarker template identification set and target position configuration data;
the placeholder set determination module is used for obtaining placeholders from templates corresponding to the target FreeMarker template identification set to obtain a placeholder set to be processed;
the placeholder dividing module is used for dividing the placeholders in the placeholder set to be processed according to the types of the placeholders to obtain a plain text placeholder set and a non-plain text placeholder set;
the first KV data pair set determining module is used for acquiring a service database, and according to the service database, service data searching and KV data pair assembling are sequentially carried out on each placeholder in the plain text placeholder set respectively to obtain a first KV data pair set;
The second KV data pair set determining module is used for acquiring a picture database, and respectively carrying out picture identification searching and KV data pair assembling in sequence for each placeholder in the non-plain text placeholder set according to the picture database to obtain a second KV data pair set;
and the target Word document determining module is used for generating Word documents based on the FreeMarker framework according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set to obtain target Word documents.
The application also proposes a computer device comprising a memory storing a computer program and a processor implementing the steps of any of the methods described above when the processor executes the computer program.
The application also proposes a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the steps of the method of any of the above.
The method, the device, the equipment and the medium for generating the Word document by the Java application are suitable for the Java application, and the Java application integrates a FreeMarker framework, and the method comprises the following steps: acquiring a Word document generation request, wherein the Word document generation request carries a target FreeMarker template identification set and target position configuration data; acquiring placeholders from templates corresponding to the target FreeMarker template identification set to obtain a placeholder set to be processed; dividing placeholders in a placeholder set to be processed according to the types of the placeholders to obtain a plain text placeholder set and a non-plain text placeholder set; acquiring a service database, and respectively carrying out service data searching and KV data pair assembling in sequence for each placeholder in a plain text placeholder set according to the service database to obtain a first KV data pair set; acquiring a picture database, and respectively carrying out picture identification searching and KV data pair assembling in sequence for each placeholder in the non-plain text placeholder set according to the picture database to obtain a second KV data pair set; based on the FreeMarker frame, word document generation is carried out according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set to obtain a target Word document, so that Word document generation based on the FreeMarker template and the FreeMarker frame is realized, a large amount of codes are not required for specific contents, a style is not required to be adjusted for specific contents, and the template, the service data and the picture are decoupled, so that the application can better adapt to the change of requirements.
Drawings
FIG. 1 is a flow chart of a method for generating Word documents by Java application according to an embodiment of the present application;
FIG. 2 is a schematic block diagram of a Java application generating Word document device according to an embodiment of the present application;
fig. 3 is a schematic block diagram of a computer device according to an embodiment of the present application.
The achievement of the objects, functional features and advantages of the present application will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
Referring to fig. 1, in an embodiment of the present application, a method for generating a Word document by a Java application is provided, where the method is applicable to the Java application, and a FreeMarker framework is integrated in the Java application, and the method includes:
s1: acquiring a Word document generation request, wherein the Word document generation request carries a target FreeMarker template identification set and target position configuration data;
s2: acquiring placeholders from templates corresponding to the target FreeMarker template identification set to obtain a placeholder set to be processed;
S3: dividing the placeholders in the placeholder set to be processed according to the types of the placeholders to obtain a plain text placeholder set and a non-plain text placeholder set;
s4: acquiring a service database, and respectively carrying out service data searching and KV data pair assembling in sequence for each placeholder in the plain text placeholder set according to the service database to obtain a first KV data pair set;
s5: acquiring a picture database, and respectively carrying out picture identification searching and KV data pair assembling in sequence for each placeholder in the non-plain text placeholder set according to the picture database to obtain a second KV data pair set;
s6: and generating Word documents according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set based on the FreeMarker frame to obtain target Word documents.
The method is suitable for Java application, and the FreeMarker framework is integrated in the Java application, and comprises the following steps: acquiring a Word document generation request, wherein the Word document generation request carries a target FreeMarker template identification set and target position configuration data; acquiring placeholders from templates corresponding to the target FreeMarker template identification set to obtain a placeholder set to be processed; dividing placeholders in a placeholder set to be processed according to the types of the placeholders to obtain a plain text placeholder set and a non-plain text placeholder set; acquiring a service database, and respectively carrying out service data searching and KV data pair assembling in sequence for each placeholder in a plain text placeholder set according to the service database to obtain a first KV data pair set; acquiring a picture database, and respectively carrying out picture identification searching and KV data pair assembling in sequence for each placeholder in the non-plain text placeholder set according to the picture database to obtain a second KV data pair set; based on the FreeMarker frame, word document generation is carried out according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set to obtain a target Word document, so that Word document generation based on the FreeMarker template and the FreeMarker frame is realized, a large amount of codes are not required for specific contents, a style is not required to be adjusted for specific contents, and the template, the service data and the picture are decoupled, so that the application can better adapt to the change of requirements.
FreeMark is a template engine, i.e., a generic tool that is based on templates and data to be changed and is used to generate output text (HTML web pages, emails, configuration files, source code, etc.).
The Java application integrates a FreeMarker framework, so that the Java application can use a template engine of the FreeMarker framework.
For S1, a Word document generation request input by a user can be obtained, a Word document generation request sent by a third-party application system can be obtained, and the Word document generation request triggered by an application program according to preset conditions can be realized. For example, the preset condition is 7 points per day, and the preset condition is not specifically limited herein.
The Word document generation request is a request for generating a Word document from a web page in a Java application.
The target FreeMark template identification set is a set of FreeMark template identifications of FreeMark templates used for generating Word documents by a Word document generation request. The target FreeMark template identification set comprises one or more FreeMark template identifications. The FreeMark template identification includes data uniquely identifying a FreeMark template, such as template name, template ID, etc.
The target position configuration data is position data of a FreeMarker template corresponding to each FreeMarker template identifier in the target FreeMarker template identifier set when a Word document is generated.
The target location configuration data includes: the method comprises the steps of FreeMark template identification and position data, wherein each FreeMark template identification corresponds to one position data.
It is understood that the target location configuration data may be a non-null value or a null value.
Optionally, when the target position configuration data is null, and the target FreeMarker template identifier set includes a plurality of FreeMarker template identifiers, the arrangement order of the FreeMarker template identifiers in the target FreeMarker template identifier set is used as the position data of the FreeMarker templates corresponding to the FreeMarker template identifiers in the target FreeMarker template identifier set when the Word document is generated.
And S2, acquiring placeholders from each FreeMarker template corresponding to the target FreeMarker template identification set, and taking all the acquired placeholders as a placeholder set to be processed.
For S3, the placeholder types include: plain text placeholders and non-plain text placeholders. The non-plain text placeholders include: picture placeholders and chart placeholders.
Wherein, the position corresponding to the plain text placeholder needs to be replaced by plain text data. The position corresponding to the picture placeholder needs to be replaced by a picture. The position corresponding to the chart placeholder needs to be replaced by a table or a picture generated by the table.
Dividing the placeholders in the placeholder set to be processed according to the types of the placeholders, taking all plain text placeholders as a plain text placeholder set, and taking all non-plain text placeholders as a non-plain text placeholder set.
For S4, the service database may be obtained from a database, or may be obtained from a third party application system.
The service database comprises: service data identification and service data. The service data identifier may be a service data ID for uniquely identifying one service data. The traffic data may be the value of one field, one of a plurality of fields.
KV data pair, namely Key-Value data format.
Optionally, extracting a placeholder from the plain text placeholder set as a first plain text placeholder to be searched; searching a preset data identifier of a first to-be-searched plain text placeholder in a FreeMarker template corresponding to the target FreeMarker template identifier set in the service database, and taking service data corresponding to a service data identifier corresponding to the preset data identifier searched in the service database as first to-be-spliced service data; assembling KV data pairs according to the first to-be-searched plain text placeholder and the first to-be-spliced service data to obtain a first to-be-processed KV data pair corresponding to the first to-be-searched plain text placeholder, wherein the first to-be-searched plain text placeholder is used as a Key of the first to-be-processed KV data pair, and the first to-be-spliced service data is used as a Value of the first to-be-processed KV data pair; repeating the step of extracting one placeholder from the plain text placeholder set as a first plain text placeholder to be searched until the extraction of the placeholder in the plain text placeholder set is completed; and taking all the first KV data pairs to be processed as the first KV data pair set.
Optionally, obtaining placeholder configuration data; extracting one placeholder from the plain text placeholder set to serve as a second plain text placeholder to be searched; searching the second plain text placeholder to be searched in the placeholder configuration data to obtain a first personalized configuration searching result; when the first personalized configuration searching result is successful, taking a configuration data identifier corresponding to the placeholder identifier of the plain text placeholder to be searched in the placeholder configuration data as a first data identifier to be searched; when the first personalized configuration searching result is failure, taking a preset data identifier of the second plain text placeholder to be searched in a FreeMarker template corresponding to the target FreeMarker template identifier set as the first data identifier to be searched; searching the first data identifier to be searched in the service database, and taking the service data corresponding to the service data identifier searched in the service database as second service data to be spliced; assembling KV data pairs according to the second plain text placeholder to be searched and the second service data to be spliced to obtain a first KV data pair to be analyzed corresponding to the second plain text placeholder to be searched, wherein the second plain text placeholder to be searched is used as the Key of the first KV data pair to be analyzed, and the second service data to be spliced is used as the Value of the first KV data pair to be analyzed; repeating the step of extracting one placeholder from the plain text placeholder set as a second plain text placeholder to be searched until the extraction of the placeholder in the plain text placeholder set is completed; and taking all the first KV data pairs to be analyzed as the first KV data pair set.
The placeholder configuration data includes: a placeholder identifier and a configuration data identifier, wherein each placeholder identifier corresponds to one configuration data identifier. The placeholder identification may be a placeholder name, a placeholder ID, etc. data uniquely identifying one placeholder. The configuration data identifier may be a service data identifier or a picture identifier. The picture identification may be data uniquely identifying one picture such as a picture name, a picture ID, or the like.
For S5, the picture database may be obtained from a database, or may be obtained from a third party application system.
The picture database includes: picture identification and pictures, each picture identification corresponds to a picture.
Optionally, extracting a placeholder from the non-plain text placeholder set as a first non-plain text placeholder to be searched; searching a preset data identifier of a first non-plain text placeholder to be searched in a FreeMarker template corresponding to the target FreeMarker template identifier set in the picture database, and taking a picture identifier corresponding to the preset data identifier searched in the picture database as a first picture identifier to be spliced; assembling KV data pairs according to the first non-plain text placeholder to be searched and the first picture identifier to be spliced to obtain a second KV data pair to be processed corresponding to the first non-plain text placeholder to be searched, wherein the first non-plain text placeholder to be searched is used as the Key of the second KV data pair to be processed, and the first picture identifier to be spliced is used as the Value of the second KV data pair to be processed; repeating the step of extracting a placeholder from the non-plain text placeholder set as a first non-plain text placeholder to be searched until the extraction of the placeholder in the non-plain text placeholder set is completed; and taking all the second KV data pairs to be processed as a second KV data pair set.
Optionally, obtaining placeholder configuration data; extracting one placeholder from the non-plain text placeholder set to serve as a second non-plain text placeholder to be searched; searching the second non-plain text placeholder to be searched in the placeholder configuration data to obtain a second personalized configuration searching result; when the second personalized configuration searching result is successful, taking a configuration data identifier corresponding to the placeholder identifier of the second non-plain text placeholder to be searched in the placeholder configuration data as a second data identifier to be searched; when the second personalized configuration searching result is failure, taking a preset data identifier of the second non-plain text placeholder to be searched in a FreeMarker template corresponding to the target FreeMarker template identifier set as the second data identifier to be searched; searching the second data identifier to be searched in the picture database, and taking the picture identifier searched in the picture database as a second picture identifier to be spliced; assembling KV data pairs according to the second non-plain text placeholder to be searched and the second picture identifier to be spliced to obtain a second KV data pair to be analyzed corresponding to the second non-plain text placeholder to be searched, wherein the second non-plain text placeholder to be searched is used as the Key of the second KV data pair to be analyzed, and the second picture identifier to be spliced is used as the Value of the second KV data pair to be analyzed; repeating the step of extracting one placeholder from the non-plain text placeholder set as a second non-plain text placeholder to be searched until the extraction of the placeholder in the non-plain text placeholder set is completed; and taking all the second KV data pairs to be analyzed as a second KV data pair set.
And S6, based on a template engine corresponding to the FreeMarker framework, performing placeholder replacement and Word document generation on the set according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set, and taking the generated Word document as the target Word document.
In one embodiment, before the step of obtaining the Word document generation request, the method includes:
s11: acquiring a template generation request;
s12: responding to the template generation request, acquiring a FreeMarker template identifier to be added, word frame data to be added, word style data to be added, a placeholder set to be added and a template object position data set to be processed, wherein the Word frame data to be added is Word frame data obtained based on Html, and the Word style data to be added is Word style data obtained based on CSS;
s13: generating a static page according to the FreeMarker template identifier to be added, the Word frame data to be added, the Word style data to be added, the placeholder set to be added and the template object position data set to be processed, so as to obtain a static page to be converted;
S14: performing flt file format conversion on the static page to be converted to obtain a FreeMarkr template to be stored;
s15: and updating the FreeMark template library according to the FreeMark template to be stored.
According to the embodiment, the static page is generated firstly, then the static page is subjected to flt file format conversion, and the file in the flt file format obtained through conversion is used as a FreeMarker template to be stored, so that the FreeMarker template is generated based on the Html and the CSS, and a basis is provided for Word document generation based on the FreeMarker template and the FreeMarker frame; the application can better adapt to the change of the requirement by setting the placeholder on the FreeMark template to decouple the template from the service data and the picture.
For S11, a template generation request input by the user may be acquired, or a template generation request sent by the third party application system may be acquired.
The template generation request is a request to generate a FreeMarker template.
And S12, responding to the template generation request, acquiring a to-be-added FreeMark template identifier, to-be-added Word frame data, to-be-added Word style data, to-be-added placeholder set and to-be-processed template object position data set which are input by a user, and acquiring the to-be-added FreeMark template identifier, to-be-added Word frame data, to-be-added Word style data, to-be-added placeholder set and to-be-processed template object position data set from a third party application system.
The Word frame data to be added are Word frame data developed by using Html (hypertext markup language). Word frame data includes: text blocks and text block configuration data. Text content and pictures can be added in the text blocks. Text block configuration data is content data of each text block, the content data not including placeholders.
The Word style data to be added is Word style data developed by using CSS (cascading style sheet). Word style data includes, but is not limited to: text style and picture style. Text styles include, but are not limited to: a text outline level, a text alignment, a text font, and a text background color. Picture styles include, but are not limited to: the picture alignment mode, whether the picture frame, the picture height and the picture width are included or not.
The FreeMark template identifier to be added is the FreeMark template identifier.
One or more placeholders are included in the set of placeholders to be added. The specific character of the placeholder may be set as desired, and is not limited herein.
The template object position data set to be processed is Word frame data to be added, word style data to be added and position data of each object in the placeholder set to be added. For example, a text block may be an object.
And S13, adopting the template object position data set to be processed, generating a static page according to the Word frame data to be added, the Word style data to be added and the placeholder set to be added, taking the generated static page as the static page to be converted, and taking the FreeMarker template identifier to be added as the page identifier of the static page to be converted.
And S14, performing flt file format conversion on the static page to be converted, and taking the file in the flt file format obtained through conversion as a FreeMarker template to be stored.
The flt file format is an openflight file of VEGA prime, and is a file for generating topography.
And S15, updating the FreeMarker template to be stored into a FreeMarker template library according to the FreeMarker template identifier to be added corresponding to the FreeMarker template to be stored.
The FreeMark template library includes: a FreeMarker template identification set and a FreeMarker template set.
In one embodiment, the step of obtaining the picture database includes:
s51: obtaining a chart placeholder from the non-plain text placeholder set to obtain a chart placeholder set;
S52: according to the service database, respectively carrying out chart generation and picture conversion in sequence for each chart placeholder in the chart placeholder set to obtain a picture set to be stored;
s53: and acquiring the picture database, and updating the picture database according to the picture set to be stored.
The embodiment realizes the sequential chart generation and the picture conversion of the chart placeholder, thereby providing support for the subsequent generation of Word documents by adopting pictures.
For S51, a chart placeholder is acquired from the non-plain text placeholder set, and all acquired chart placeholders are taken as a chart placeholder set.
For S52, extracting a placeholder from the set of chart placeholders as a first chart placeholder to be searched; searching a preset data identifier of a first chart placeholder to be searched in a FreeMarker template corresponding to the target FreeMarker template identifier set in the service database, and taking service data corresponding to the service data identifier searched in the service database as service data of the first chart to be generated; adopting a chart generation plug-in, and performing chart generation according to the business data of the first chart to be generated to obtain a first chart to be converted; performing picture conversion according to the first to-be-converted chart to obtain a first to-be-stored picture; repeating the step of extracting one placeholder from the chart placeholder set as a first to-be-searched chart placeholder until the extraction of the placeholder in the chart placeholder set is completed; and taking all the first pictures to be stored as the picture set to be stored.
Optionally, obtaining placeholder configuration data; extracting one placeholder from the chart placeholder set to serve as a second chart placeholder to be searched; searching the second diagram placeholder to be searched in the placeholder configuration data to obtain a third personalized configuration searching result; when the third personalized configuration searching result is successful, taking a configuration data identifier corresponding to the placeholder identifier of the chart placeholder to be searched in the placeholder configuration data as a third data identifier to be searched; when the third personalized configuration searching result is failure, taking a preset data identifier of the chart placeholder to be searched in the FreeMarker template corresponding to the target FreeMarker template identifier set as the third data identifier to be searched; searching the third data identifier to be searched in the service database, and taking the service data corresponding to the service data identifier searched in the service database as the service data of a second chart to be generated; adopting a chart generation plug-in, and performing chart generation according to the business data of the second chart to be generated to obtain a second chart to be converted; performing picture conversion according to the second chart to be converted to obtain a second picture to be stored; repeating the step of extracting one placeholder from the chart placeholder set as a second chart placeholder to be searched until the extraction of the placeholder in the chart placeholder set is completed; and taking all the second pictures to be stored as the picture set to be stored.
The chart generation plug-in can generate a table and a chart according to the service data, and specific implementation steps are not described herein.
And for S53, acquiring the picture database, and updating the picture set to be stored into the picture database.
In one embodiment, the step of generating a Word document based on the FreeMarker framework according to the picture database, the target FreeMarker template identifier set, the target position configuration data, the first KV data pair set and the second KV data pair set to obtain a target Word document includes:
s61: based on the FreeMarker frame, acquiring a FreeMarker template library, and constructing a document frame according to the FreeMarker template library, the target FreeMarker template identification set and the target position configuration data to obtain a flt file to be replaced;
s62: and generating Word documents according to the flt file to be replaced, the picture database, the first KV data pair set and the second KV data pair set based on the FreeMarker framework, and obtaining the target Word documents.
According to the embodiment, the method and the device for generating the Word document based on the FreeMarker frame, the document frame is built firstly, and then the Word document is generated, so that the Word document is generated based on the FreeMarker template and the FreeMarker frame, a large amount of codes are not needed for specific contents, and the style is not needed to be adjusted for specific contents.
For S61, based on the FreeMarker framework, the FreeMarker template library may be obtained from a database, or may be obtained from a third-party application system.
And constructing a document frame based on the template engine corresponding to the FreeMarker frame, adopting the target position configuration data, and constructing a file in a flt file format according to the FreeMarker template library and the target FreeMarker template identification set, wherein the constructed file is used as the flt file to be replaced.
And S62, replacing placeholders in the flt file to be replaced based on a template engine corresponding to the FreeMarker framework according to the picture database, the first KV data pair set and the second KV data pair set, performing Word document format conversion on the flt file to be replaced after replacement, and taking the file in the Word document format obtained through conversion as the target Word document.
The Word document format includes: DOC, DOCX.
In one embodiment, the step of generating a Word document based on the FreeMarker framework according to the flt file to be replaced, the picture database, the first KV data pair set and the second KV data pair set to obtain the target Word document includes:
S621: based on the FreeMark frame, replacing the placeholders in the flt file to be replaced according to the picture database, the first KV data pair set and the second KV data pair set to obtain the flt file to be converted;
s622: and converting the format of the Word document to the flt file to be converted based on the FreeMarker framework to obtain the target Word document.
According to the embodiment, based on the FreeMarker framework, the placeholders in the flt file to be replaced are replaced and Word document format conversion is carried out according to the first KV data pair set and the second KV data pair set, so that Word document generation based on the FreeMarker template and the FreeMarker framework is realized, a large amount of encoding is not needed for specific content, and a style is not needed to be adjusted for specific content.
For S621, based on FreeMarker Template class (template writing class) of the template engine corresponding to the FreeMarker framework, replacing the placeholder in the flt file to be replaced with the Value of the first KV data pair set, acquiring a picture from the picture database with the Value of the second KV data pair set, replacing the placeholder in the flt file to be replaced with the acquired picture, and taking the flt file to be replaced after replacement as the flt file to be converted.
And S622, converting a Word document format of the flt file to be converted based on a template engine template process method corresponding to the FreeMarker framework, and taking the file in the Word document format obtained by conversion as the target Word document.
In one embodiment, a Word-to-PDF plug-in is integrated in the Java application, where the Word-to-PDF plug-in is a plug-in obtained based on OpenOffice;
the step of generating Word documents based on the FreeMarker framework according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set to obtain target Word documents further comprises the following steps:
s7: acquiring a PDF conversion request;
s8: responding to the PDF conversion request, and sending the target Word document to the Word PDF conversion plug-in;
s9: and based on the Word-to-PDF plug-in, performing PDF file format conversion on the target Word document to obtain the target PDF document.
Because Microsoft does not have an interface for converting Java open Word document format into PDF file format, partial content loss, picture position change and picture and text overlapping can occur when using Apache POI to convert according to Word document, in order to solve the problems, in the embodiment, the Word document is converted into PDF file format by using plug-in based on Openoffice, and the Openoffice has excellent support for decoding and transcoding of Word, thereby improving the accuracy of PDF conversion.
OpenOoffice is a cross-platform suite of office software that can be executed on operating systems such as Windows, linux, macOS X (X11), solaris, and the like.
For S7, a request for converting PDF input by the user may be obtained, or a request for converting PDF sent by the third party application system may be obtained.
A PDF conversion request, that is, a request to convert a Word document format to a PDF file format.
PDF, an acronym for Portable Document Format, means portable document format.
And S8, responding to the PDF conversion request, converting the target Word document into a file stream, and transmitting the converted file stream to the Word PDF conversion plug-in.
And S9, decoding the target Word document based on the Word converting PDF plug-in, performing PDF file format transcoding on the decoded data, and taking the file in the PDF file format obtained by transcoding as the target PDF document.
In one embodiment, the step of performing PDF file format conversion on the target Word document based on the Word-to-PDF plug-in to obtain the target PDF document includes:
s91: acquiring a preset storage address;
s92: performing PDF file format conversion on the target Word document by adopting an Office document converter of the Word-to-PDF plug-in unit to obtain the target PDF document;
S93: and storing the target PDF document into a folder corresponding to the preset storage address.
In the embodiment, the Office document converter of the Word-to-PDF plug-in is adopted to convert the PDF file format, and the Word-to-PDF plug-in is a plug-in obtained based on OpenOffice, so that the OpenOffice has excellent support for decoding and transcoding of the Word, and the accuracy of PDF conversion is improved.
For S91, a preset storage address input by the user may be acquired.
The preset storage address is a link address of a folder for presetting and storing the target PDF document.
And S92, decoding the target Word document and transcoding the PDF file format by adopting an Office document converter of the Word-to-PDF plug-in, and taking the PDF file format obtained by transcoding as the target PDF document.
Office document converter, office DocumentConverter.
Referring to fig. 2, the application further provides a device for generating a Word document by using a Java application, the device is suitable for the Java application, a FreeMarker framework is integrated in the Java application, and the device comprises:
the request acquisition module 100 is configured to acquire a Word document generation request, where the Word document generation request carries a target FreeMarker template identifier set and target position configuration data;
The placeholder set determination module 200 to be processed is configured to obtain a placeholder from a template corresponding to the target FreeMarker template identifier set, so as to obtain a placeholder set to be processed;
the placeholder dividing module 300 is configured to divide the placeholders in the placeholder set to be processed according to the types of the placeholders, so as to obtain a plain text placeholder set and a non-plain text placeholder set;
the first KV data pair set determining module 400 is configured to obtain a service database, and according to the service database, perform service data search and KV data pair assembly in sequence for each placeholder in the plain text placeholder set, to obtain a first KV data pair set;
the second KV data pair set determining module 500 is configured to obtain a picture database, and according to the picture database, perform picture identification search and KV data pair assembly in sequence for each placeholder in the non-plain text placeholder set, to obtain a second KV data pair set;
and the target Word document determining module 600 is configured to generate a Word document based on the FreeMarker framework according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set, so as to obtain a target Word document.
The method is suitable for Java application, and the FreeMarker framework is integrated in the Java application, and comprises the following steps: acquiring a Word document generation request, wherein the Word document generation request carries a target FreeMarker template identification set and target position configuration data; acquiring placeholders from templates corresponding to the target FreeMarker template identification set to obtain a placeholder set to be processed; dividing placeholders in a placeholder set to be processed according to the types of the placeholders to obtain a plain text placeholder set and a non-plain text placeholder set; acquiring a service database, and respectively carrying out service data searching and KV data pair assembling in sequence for each placeholder in a plain text placeholder set according to the service database to obtain a first KV data pair set; acquiring a picture database, and respectively carrying out picture identification searching and KV data pair assembling in sequence for each placeholder in the non-plain text placeholder set according to the picture database to obtain a second KV data pair set; based on the FreeMarker frame, word document generation is carried out according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set to obtain a target Word document, so that Word document generation based on the FreeMarker template and the FreeMarker frame is realized, a large amount of codes are not required for specific contents, a style is not required to be adjusted for specific contents, and the template, the service data and the picture are decoupled, so that the application can better adapt to the change of requirements.
Referring to fig. 3, in an embodiment of the present application, there is further provided a computer device, which may be a server, and an internal structure thereof may be as shown in fig. 3. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the computer is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer equipment is used for storing data such as a method for generating Word documents by Java application. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a method for generating Word documents by a Java application. The Java application generates a Word document method, the method is suitable for Java applications, a FreeMarker framework is integrated in the Java applications, and the method comprises the following steps: acquiring a Word document generation request, wherein the Word document generation request carries a target FreeMarker template identification set and target position configuration data; acquiring placeholders from templates corresponding to the target FreeMarker template identification set to obtain a placeholder set to be processed; dividing the placeholders in the placeholder set to be processed according to the types of the placeholders to obtain a plain text placeholder set and a non-plain text placeholder set; acquiring a service database, and respectively carrying out service data searching and KV data pair assembling in sequence for each placeholder in the plain text placeholder set according to the service database to obtain a first KV data pair set; acquiring a picture database, and respectively carrying out picture identification searching and KV data pair assembling in sequence for each placeholder in the non-plain text placeholder set according to the picture database to obtain a second KV data pair set; and generating Word documents according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set based on the FreeMarker frame to obtain target Word documents.
The method is suitable for Java application, and the FreeMarker framework is integrated in the Java application, and comprises the following steps: acquiring a Word document generation request, wherein the Word document generation request carries a target FreeMarker template identification set and target position configuration data; acquiring placeholders from templates corresponding to the target FreeMarker template identification set to obtain a placeholder set to be processed; dividing placeholders in a placeholder set to be processed according to the types of the placeholders to obtain a plain text placeholder set and a non-plain text placeholder set; acquiring a service database, and respectively carrying out service data searching and KV data pair assembling in sequence for each placeholder in a plain text placeholder set according to the service database to obtain a first KV data pair set; acquiring a picture database, and respectively carrying out picture identification searching and KV data pair assembling in sequence for each placeholder in the non-plain text placeholder set according to the picture database to obtain a second KV data pair set; based on the FreeMarker frame, word document generation is carried out according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set to obtain a target Word document, so that Word document generation based on the FreeMarker template and the FreeMarker frame is realized, a large amount of codes are not required for specific contents, a style is not required to be adjusted for specific contents, and the template, the service data and the picture are decoupled, so that the application can better adapt to the change of requirements.
An embodiment of the present application further provides a computer readable storage medium having a computer program stored thereon, the computer program when executed by a processor implementing a method for generating Word documents by a Java application, the method being applicable to the Java application, in which a FreeMarker framework is integrated, the method comprising: acquiring a Word document generation request, wherein the Word document generation request carries a target FreeMarker template identification set and target position configuration data; acquiring placeholders from templates corresponding to the target FreeMarker template identification set to obtain a placeholder set to be processed; dividing the placeholders in the placeholder set to be processed according to the types of the placeholders to obtain a plain text placeholder set and a non-plain text placeholder set; acquiring a service database, and respectively carrying out service data searching and KV data pair assembling in sequence for each placeholder in the plain text placeholder set according to the service database to obtain a first KV data pair set; acquiring a picture database, and respectively carrying out picture identification searching and KV data pair assembling in sequence for each placeholder in the non-plain text placeholder set according to the picture database to obtain a second KV data pair set; and generating Word documents according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set based on the FreeMarker frame to obtain target Word documents.
The method for generating the Word document by the Java application is suitable for Java application, and the FreeMarker framework is integrated in the Java application, and comprises the following steps: acquiring a Word document generation request, wherein the Word document generation request carries a target FreeMarker template identification set and target position configuration data; acquiring placeholders from templates corresponding to the target FreeMarker template identification set to obtain a placeholder set to be processed; dividing placeholders in a placeholder set to be processed according to the types of the placeholders to obtain a plain text placeholder set and a non-plain text placeholder set; acquiring a service database, and respectively carrying out service data searching and KV data pair assembling in sequence for each placeholder in a plain text placeholder set according to the service database to obtain a first KV data pair set; acquiring a picture database, and respectively carrying out picture identification searching and KV data pair assembling in sequence for each placeholder in the non-plain text placeholder set according to the picture database to obtain a second KV data pair set; based on the FreeMarker frame, word document generation is carried out according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set to obtain a target Word document, so that Word document generation based on the FreeMarker template and the FreeMarker frame is realized, a large amount of codes are not required for specific contents, a style is not required to be adjusted for specific contents, and the template, the service data and the picture are decoupled, so that the application can better adapt to the change of requirements.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium provided by the present application and used in embodiments may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual speed data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, apparatus, article or method that comprises the element.
The foregoing description is only of the preferred embodiments of the present application and is not intended to limit the scope of the application, and all equivalent structures or equivalent processes using the descriptions and drawings of the present application or directly or indirectly applied to other related technical fields are included in the scope of the application.

Claims (7)

1. A method for generating Word documents by a Java application, the method being suitable for the Java application, wherein a FreeMarker framework is integrated in the Java application, the method comprising:
acquiring a Word document generation request, wherein the Word document generation request carries a target FreeMarker template identification set and target position configuration data;
Acquiring placeholders from templates corresponding to the target FreeMarker template identification set to obtain a placeholder set to be processed;
dividing the placeholders in the placeholder set to be processed according to the types of the placeholders to obtain a plain text placeholder set and a non-plain text placeholder set;
acquiring a service database, and respectively carrying out service data searching and KV data pair assembling in sequence for each placeholder in the plain text placeholder set according to the service database to obtain a first KV data pair set;
acquiring a picture database, and respectively carrying out picture identification searching and KV data pair assembling in sequence for each placeholder in the non-plain text placeholder set according to the picture database to obtain a second KV data pair set;
based on the FreeMarker framework, word document generation is carried out according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set, and a target Word document is obtained;
before the step of obtaining the Word document generation request, the method comprises the following steps:
acquiring a template generation request;
Responding to the template generation request, acquiring a FreeMarker template identifier to be added, word frame data to be added, word style data to be added, a placeholder set to be added and a template object position data set to be processed, wherein the Word frame data to be added is Word frame data obtained based on Html, and the Word style data to be added is Word style data obtained based on CSS;
generating a static page according to the FreeMarker template identifier to be added, the Word frame data to be added, the Word style data to be added, the placeholder set to be added and the template object position data set to be processed, so as to obtain a static page to be converted;
performing flt file format conversion on the static page to be converted to obtain a FreeMarkr template to be stored;
updating a FreeMarker template library according to the FreeMarker template to be stored;
the step of generating Word documents based on the FreeMarker framework according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set to obtain target Word documents comprises the following steps:
Based on the FreeMarker frame, acquiring a FreeMarker template library, and constructing a document frame according to the FreeMarker template library, the target FreeMarker template identification set and the target position configuration data to obtain a flt file to be replaced;
based on the FreeMarker framework, generating Word documents according to the flt file to be replaced, the picture database, the first KV data pair set and the second KV data pair set to obtain the target Word document;
the step of generating a Word document based on the FreeMarker framework according to the flt file to be replaced, the picture database, the first KV data pair set and the second KV data pair set to obtain the target Word document comprises the following steps:
based on the FreeMark frame, replacing the placeholders in the flt file to be replaced according to the picture database, the first KV data pair set and the second KV data pair set to obtain the flt file to be converted;
and converting the format of the Word document to the flt file to be converted based on the FreeMarker framework to obtain the target Word document.
2. The method for generating Word documents by Java application according to claim 1, wherein said step of obtaining a picture database comprises:
Obtaining a chart placeholder from the non-plain text placeholder set to obtain a chart placeholder set;
according to the service database, respectively carrying out chart generation and picture conversion in sequence for each chart placeholder in the chart placeholder set to obtain a picture set to be stored;
and acquiring the picture database, and updating the picture database according to the picture set to be stored.
3. The method for generating a Word document by using a Java application according to claim 1, wherein a Word-to-PDF plug-in is integrated in the Java application, and the Word-to-PDF plug-in is a plug-in obtained based on OpenOoffice;
the step of generating Word documents based on the FreeMarker framework according to the picture database, the target FreeMarker template identification set, the target position configuration data, the first KV data pair set and the second KV data pair set to obtain target Word documents further comprises the following steps:
acquiring a PDF conversion request;
responding to the PDF conversion request, and sending the target Word document to the Word PDF conversion plug-in;
and based on the Word-to-PDF plug-in, performing PDF file format conversion on the target Word document to obtain the target PDF document.
4. The method for generating a Word document by using a Java application according to claim 3, wherein the step of performing PDF file format conversion on the target Word document based on the Word-to-PDF plug-in to obtain the target PDF document includes:
acquiring a preset storage address;
performing PDF file format conversion on the target Word document by adopting an Office document converter of the Word-to-PDF plug-in unit to obtain the target PDF document;
and storing the target PDF document into a folder corresponding to the preset storage address.
5. A Java application generation Word document device, wherein the device is adapted for a Java application, and the Java application integrates a FreeMarker framework therein, and the device comprises:
the request acquisition module is used for acquiring a template generation request;
responding to the template generation request, acquiring a FreeMarker template identifier to be added, word frame data to be added, word style data to be added, a placeholder set to be added and a template object position data set to be processed, wherein the Word frame data to be added is Word frame data obtained based on Html, and the Word style data to be added is Word style data obtained based on CSS;
Generating a static page according to the FreeMarker template identifier to be added, the Word frame data to be added, the Word style data to be added, the placeholder set to be added and the template object position data set to be processed, so as to obtain a static page to be converted;
performing flt file format conversion on the static page to be converted to obtain a FreeMarkr template to be stored;
updating a FreeMarker template library according to the FreeMarker template to be stored;
acquiring a Word document generation request, wherein the Word document generation request carries a target FreeMarker template identification set and target position configuration data;
the placeholder set determination module is used for obtaining placeholders from templates corresponding to the target FreeMarker template identification set to obtain a placeholder set to be processed;
the placeholder dividing module is used for dividing the placeholders in the placeholder set to be processed according to the types of the placeholders to obtain a plain text placeholder set and a non-plain text placeholder set;
the first KV data pair set determining module is used for acquiring a service database, and according to the service database, service data searching and KV data pair assembling are sequentially carried out on each placeholder in the plain text placeholder set respectively to obtain a first KV data pair set;
The second KV data pair set determining module is used for acquiring a picture database, and respectively carrying out picture identification searching and KV data pair assembling in sequence for each placeholder in the non-plain text placeholder set according to the picture database to obtain a second KV data pair set;
the target Word document determining module is used for acquiring a FreeMarker template library based on the FreeMarker frame, and constructing a document frame according to the FreeMarker template library, the target FreeMarker template identification set and the target position configuration data to obtain a flt file to be replaced;
based on the FreeMark frame, replacing the placeholders in the flt file to be replaced according to the picture database, the first KV data pair set and the second KV data pair set to obtain the flt file to be converted;
and converting the format of the Word document to the flt file to be converted based on the FreeMarker framework to obtain the target Word document.
6. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 4 when the computer program is executed.
7. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 4.
CN202110691923.6A 2021-06-22 2021-06-22 Method, device, equipment and medium for generating Word document by Java application Active CN113408244B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110691923.6A CN113408244B (en) 2021-06-22 2021-06-22 Method, device, equipment and medium for generating Word document by Java application

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110691923.6A CN113408244B (en) 2021-06-22 2021-06-22 Method, device, equipment and medium for generating Word document by Java application

Publications (2)

Publication Number Publication Date
CN113408244A CN113408244A (en) 2021-09-17
CN113408244B true CN113408244B (en) 2023-08-22

Family

ID=77682434

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110691923.6A Active CN113408244B (en) 2021-06-22 2021-06-22 Method, device, equipment and medium for generating Word document by Java application

Country Status (1)

Country Link
CN (1) CN113408244B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101976235A (en) * 2010-09-21 2011-02-16 天津神舟通用数据技术有限公司 Extensible Word report automatically-generating method based on dynamic web page
CN106874244A (en) * 2017-01-03 2017-06-20 宁波大红鹰学院 A kind of construction method of the document Auto-generation Model based on work sequence
WO2020232872A1 (en) * 2019-05-22 2020-11-26 平安科技(深圳)有限公司 Table recognition method and apparatus, computer device, and storage medium
WO2020238054A1 (en) * 2019-05-30 2020-12-03 平安科技(深圳)有限公司 Method and apparatus for positioning chart in pdf document, and computer device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101976235A (en) * 2010-09-21 2011-02-16 天津神舟通用数据技术有限公司 Extensible Word report automatically-generating method based on dynamic web page
CN106874244A (en) * 2017-01-03 2017-06-20 宁波大红鹰学院 A kind of construction method of the document Auto-generation Model based on work sequence
WO2020232872A1 (en) * 2019-05-22 2020-11-26 平安科技(深圳)有限公司 Table recognition method and apparatus, computer device, and storage medium
WO2020238054A1 (en) * 2019-05-30 2020-12-03 平安科技(深圳)有限公司 Method and apparatus for positioning chart in pdf document, and computer device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
利用Java技术动态生成Word文档之探索;叶文胜;;黄冈职业技术学院学报(第06期);全文 *

Also Published As

Publication number Publication date
CN113408244A (en) 2021-09-17

Similar Documents

Publication Publication Date Title
CN108446116B (en) Application program page generation method and device, computer equipment and storage medium
CN109933752B (en) Method and device for exporting electronic document
CN108804159B (en) Javascript module loading method and preprocessing method and device thereof, and computer equipment
CN110162524B (en) Configuration data management method, device, computer equipment and storage medium
CN110347985B (en) Method, device, computer equipment and storage medium for generating table
CN110780860A (en) Generation method and device of table building script, computer equipment and storage medium
WO2019153979A1 (en) Text translation method, apparatus, computer device and storage medium
CN109857389B (en) Model data generation method and device, computer equipment and storage medium
CN113382083B (en) Webpage screenshot method and device
CN112527291A (en) Webpage generation method and device, electronic equipment and storage medium
CN112541018A (en) Bank pipelining processing method and device combining RPA and AI and electronic equipment
CN112131837A (en) Service report configuration method, device, computer equipment and storage medium
CN116227505A (en) Internationalization file translation method, device, equipment and medium
CN110362630B (en) Data management method, device, equipment and computer readable storage medium
CN113408244B (en) Method, device, equipment and medium for generating Word document by Java application
CN113296752A (en) Method, system, device and storage medium for generating API document
CN115841095A (en) Document establishing method, system, medium and equipment
CN114968346A (en) Method, device, equipment and storage medium for detecting field comments of DDL script
CN109657178B (en) Page form processing method and device, computer equipment and storage medium
CN114417812A (en) Text checking method, device, equipment and storage medium
CN115328455A (en) Information display method, device, equipment and medium for flutter application
CN112632946A (en) Method, apparatus, computer device and storage medium for automatic table building
CN113239670A (en) Method and device for uploading service template, computer equipment and storage medium
CN111209759A (en) Webpage translation method and device, computer equipment and storage medium
CN113961244B (en) Page conversion method, device, equipment and storage 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