Report filling method and storage medium thereof

By adopting a modular design in the report system, custom parsing and filling out the document elements, charts and attachments of the report file, the problem of lack of flexibility in the filling process of the existing report system is solved, and diversified report output effects and improved user experience are achieved.

CN119940326AActive Publication Date: 2025-05-06DINGLI COMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411993607.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-05-06
Estimated Expiration
2044-12-31

AI Technical Summary

Technical Problem

The report filling process of the existing report system is limited to fixed formats or single purpose, and lacks flexibility, making it difficult to meet users' diverse and personalized needs for report templates.

Method used

By customizing the template file, modular analysis and filling of document elements, charts and attachments of the report file can be achieved, supporting flexible responses to different scenarios and needs.

Benefits of technology

It improves the scalability of report filling, improves user experience and application value, and achieves diversified report output effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119940326A_ABST
    Figure CN119940326A_ABST
Patent Text Reader

Abstract

The invention provides a report filling method and a storage medium thereof. By customizing a template file path, reading and copying a custom template file in a database to obtain a target report file, performing document analysis on the target report file to obtain a document element, and according to the content of the document element, performing report filling according to the content of the document element. The method comprises the following steps of: reading document data from a database and backfilling the document data to document elements, then performing chart analysis on a target report file to obtain a target chart, reading a chart numerical source from a worksheet of the target chart according to a chart title of the target chart, backfilling the chart numerical source to the target chart, then performing attachment analysis on the target report file, and obtaining the target chart. According to the method, the target attachment is obtained, the internal parameters of the target attachment are cloned, the target clone data are obtained, the external data are obtained from the database according to the target clone data, the external data and the target clone data are combined, the attachment updating data are obtained and written back to the attachment, and therefore the expandability of report filling is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of reports, and in particular to a report filling method and a storage medium thereof. Background Art

[0002] In the process of information management and data processing, various reporting systems are important tools for data recording, analysis and display.

[0003] However, the report filling process of existing report systems is often limited to fixed formats or single purposes, lacking flexibility and difficult to meet users' needs for diversified and personalized report templates. In actual applications, different scenarios have various requirements for the structure, content and output effects of reports. How to generate corresponding customized outputs based on different input templates has become a key direction for optimizing the report filling process. Summary of the invention

[0004] The main purpose of the embodiment of the present application is to propose a report filling method and its storage medium, which realizes diversified report output effects through customized template files, and parses and fills the document elements, charts and attachments of the target report files respectively with a modular design concept, which can flexibly respond to different scenarios and needs, improve the scalability of report filling, and enhance the user experience and application value.

[0005] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a report filling method, comprising: In response to a request for filling in a report, according to the custom template file path in the request, the custom template file in the database is read, and the custom template file is copied to obtain a target report file; Parse the target report file to obtain document elements, read the corresponding document data from the database according to the content in the document elements, and fill the document data back into the document elements; Parse the target report file to obtain the target chart, read the corresponding chart value source from the worksheet of the target chart according to the chart title of the target chart, fill the chart value source back into the target chart, and redraw the target chart; Parse the attachment of the target report file to obtain the target attachment, clone the internal parameters of the target attachment to obtain the target clone data, obtain external data from the database according to the target clone data, merge the external data with the target clone data to obtain the attachment update data, and write the attachment update data back to the attachment; Save the target report file.

[0006] Furthermore, in some embodiments, reading corresponding document data from a database according to the content in the document element, and backfilling the document data into the document element includes: When the document element is a paragraph element, the paragraph element is parsed, and the content of the paragraph element is detected to determine whether there is a first placeholder tag, and according to the first placeholder tag, corresponding document data is read from a database, and the first placeholder tag is replaced with the document data; Alternatively, when the document element is a table element, the corresponding document data is read from the database according to the content in the table element, and the document data is backfilled into the table element.

[0007] Further, in some embodiments, the table element includes a plurality of cells, and the document data includes first text data and second text data; Among them, according to the content in the table element, reading the corresponding document data from the database and filling the document data back into the table element includes the following steps: Parse the content of each cell, and detect whether the content of each cell has a second placeholder tag. If so, clear the second placeholder tag in each cell, and read the corresponding first text data from the database according to each second placeholder tag; Read the fill direction parameter of the table element, and fill the corresponding first text data in each cell in turn according to the fill direction parameter; Paragraph parsing is performed on each cell after being filled with data, and each cell's paragraph text is checked to see if there is a third placeholder tag. If so, the corresponding second text data is read from the database based on each third placeholder tag, and each third placeholder tag is replaced with the corresponding second text data, and the paragraph text of each cell is reset.

[0008] Furthermore, in some embodiments, the document data further includes extended data, and reading the corresponding document data from the database according to the content in the table element, and backfilling the document data into the table element, further includes the following steps: Read the automatic expansion parameters of the table element, and determine whether the table element needs to be automatically expanded according to the automatic expansion parameters; If the table element needs to be automatically expanded, the expansion data is read from the database according to the automatic expansion parameters, and a new row is dynamically inserted from the table element according to the row and column layout of the table element, wherein the new row includes a plurality of cells; Fill each cell in the new row with extended data in turn.

[0009] Furthermore, in some embodiments, filling the corresponding first text data into each cell in turn according to the filling direction parameter includes: When the filling direction parameter is characterized by a row direction, each cell is filled with the corresponding first text data in sequence in the row direction; Alternatively, when the filling direction parameter is characterized by a column direction, each cell is filled with the corresponding first text data in sequence along the column direction.

[0010] Further, in some embodiments, according to the chart title of the target chart, reading the corresponding chart value source from the worksheet of the target chart, and backfilling the chart value source into the target chart includes: According to the chart title, read the streaming workbook corresponding to the target chart; Convert the streaming workbook to an operation workbook and set the operation workbook to the target chart; Read the data series in the target chart; If reading of data series fails, repair the plotting area of ​​the target chart; If the data series is read successfully, the corresponding data range formula is obtained according to the data series, and the corresponding chart value source is read from the worksheet of the target chart according to the data range formula, and the chart value source is backfilled into the data series of the target chart.

[0011] Furthermore, in some embodiments, the target report file is parsed for attachments to obtain target attachments, including: Parse the attachment of the target report file to obtain the first attachment; Determine whether the file extensions of the first attachment and the target report file are consistent; If the file extensions of the first attachment and the target report file are inconsistent, the first attachment is determined as the target attachment; Alternatively, if the file extensions of the first attachment and the target report file are the same, the first attachment will be parsed to obtain the second attachment. If the file extensions of the second attachment and the target report file are the same, the second attachment will be used as the first attachment again, and the process will return to the step of parsing the first attachment to obtain the second attachment, until the file extensions of the second attachment and the target report file are inconsistent, in which case the second attachment will be determined as the target attachment.

[0012] Further, in some embodiments, the target clone data includes first clone data, second clone data, and third clone data, cloning internal parameters of the target attachment to obtain the target clone data, and acquiring external data from a database according to the target clone data, and merging the external data with the target clone data to obtain the attachment update data, including: Clone the style of the target attachment to obtain the first clone data; Clone the image of the target attachment to obtain the second clone data; Clone the data of the source worksheet of the target attachment to obtain the third clone data; According to the third clone data, the external data is obtained from the database.

[0013] The external data, the first clone data, the second clone data, and the third clone data are merged to obtain the attachment update data.

[0014] Furthermore, in some embodiments, writing the attachment update data back to the attachment includes: Update data according to the attachment and build the target workbook of the attachment; Write the target workbook to the attachment's memory stream; Write the data in the memory stream back to the output stream of the attachment.

[0015] To achieve the above-mentioned purpose, the second aspect of the embodiment of the present application proposes a storage medium, which is a computer-readable storage medium. The storage medium stores a computer program, and when the computer program is executed by the processor, the report filling method of the above-mentioned first aspect embodiment is implemented.

[0016] The embodiments of the present application have the following beneficial effects: the present application responds to a request for report filling, reads a custom template file in a database according to a custom template file path in the request, and copies the custom template file to obtain a target report file. Then, the target report file is parsed to obtain a document element. According to the content in the document element, the corresponding document data is read from the database, and the document data is backfilled into the document element. Then, the target report file is parsed to obtain a target chart. According to the chart title of the target chart, the corresponding chart value source is read from the worksheet of the target chart, and the chart value source is backfilled into the target chart, and the target chart is redrawn. Table, then, parse the attachment of the target report file to obtain the target attachment, clone the internal parameters of the target attachment to obtain the target clone data, and obtain external data from the database according to the target clone data, merge the external data with the target clone data to obtain the attachment update data, and write the attachment update data back to the attachment, and finally, save the target report file, and then based on the customized template file, realize the diversified report output effect, and with the modular design idea, respectively parse and fill in the document elements, charts and attachments of the target report file, which can flexibly respond to different scenarios and needs, improve the scalability of report filling, and enhance the user experience and application value. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 is a flow chart of a report filling method provided by some embodiments of the present application; Figure 2is a flowchart of step S102 provided in some embodiments of the present application; Figure 3 Some embodiments of the present application provide Figure 2 Flow chart of step S202; Figure 4 Some embodiments of the present application provide Figure 2 Flow chart of step S202; Figure 5 Some embodiments of the present application provide Figure 3 Flowchart of step S302; Figure 6 is a flow chart for reading a chart value source according to a chart title provided by some embodiments of the present application; Figure 7 is a flow chart of parsing attachments of a target report file provided by some embodiments of the present application; Figure 8 is a flow chart of cloning a target attachment and merging external data with target clone data provided by some embodiments of the present application; Fig. 9 is a flowchart of a process of writing attachment update data back to an attachment provided by other embodiments of the present application; Fig.10 It is a schematic diagram of the hardware structure of an electronic device provided in some embodiments of the present application. DETAILED DESCRIPTION

[0018] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0019] In the description of the present application, it should be understood that descriptions involving orientation, such as up, down, front, back, left, right, etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.

[0020] It should also be noted that in the description of this application, "several" means more than one, "more" means more than two, "greater than", "less than", "exceed", etc. are understood to exclude the number itself, and "above", "below", "within", etc. are understood to include the number itself. If there is a description of "first" or "second", it is only used to distinguish the technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.

[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0022] In the description of the present application, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0023] The report filling process of the existing report system is often limited to a fixed format or a single purpose, lacking flexibility and difficult to meet users' needs for diversified and personalized report templates. In actual applications, different scenarios have various requirements for the structure, content and output effects of reports. How to generate corresponding customized outputs based on different input templates has become a key direction for optimizing the report filling process.

[0024] Based on this, the present application responds to a request for report filling, reads the custom template file in the database according to the custom template file path in the request, and copies the custom template file to obtain a target report file. Then, the target report file is parsed to obtain a document element. According to the content in the document element, the corresponding document data is read from the database, and the document data is backfilled into the document element. Then, the target report file is parsed to obtain a target chart. According to the chart title of the target chart, the corresponding chart value source is read from the worksheet of the target chart, and the chart value source is backfilled into the target chart, and the target chart is redrawn. Then, the target The target report file is parsed for attachment to obtain the target attachment, and the internal parameters of the target attachment are cloned to obtain the target clone data, and external data is obtained from the database according to the target clone data, and the external data is merged with the target clone data to obtain the attachment update data, and the attachment update data is written back to the attachment, and finally, the target report file is saved, and then based on the customized template file, a variety of report output effects are achieved, and the document elements, charts and attachments of the target report file are parsed and filled in respectively with a modular design idea, which can flexibly respond to different scenarios and needs, improve the scalability of report filling, and enhance the user experience and application value.

[0025] A report filling method and a storage medium thereof provided in an embodiment of the present application are specifically described through the following embodiments.

[0026] In the first aspect, a report filling method in an embodiment of the present application is first described. The report filling method is applied to a report filling system. The report filling system includes a server based on a Java framework and a SQLite database. The server based on the Java framework is communicatively connected with the SQLite database.

[0027] It should be noted that the Java framework is an ideal choice for flexible application of report filling due to its cross-platform characteristics, powerful ecosystem and good security. At the same time, SQLite, as a lightweight embedded database, has the advantages of low resource usage, easy deployment, and support for transaction processing, which is very suitable for small and medium-sized data management scenarios. Combining the two and applying them to the report filling method of this application can provide users with flexible and changeable template configuration and data output functions while maintaining high performance and low complexity of the report filling system.

[0028] Reference Figure 1 As shown, Figure 1 It is a flowchart of a report filling method provided in some embodiments of the present application. The report filling method may include but is not limited to steps S101 to S105.

[0029] Step S101: in response to a request for filling in a report, according to the custom template file path in the request, the custom template file in the database is read, and the custom template file is copied to obtain a target report file.

[0030] Among them, the server based on the Java framework reads and loads all tables in all SQLite databases. When responding to a request for report filling, it reads the custom template file in the SQLite database through the JDBC interface of the Java framework according to the custom template file path in the request, and copies the custom template file to obtain the target report file.

[0031] Step S102: parsing the target report file to obtain a document element, reading corresponding document data from a database according to the content in the document element, and filling the document data back into the document element.

[0032] Specifically, the target report file is parsed through the first parsing interface document.getElementbyId of the Java framework to obtain the document element IBoyElement, and the corresponding document data is read from the SQLite database according to the content in the document element, and the document data is backfilled into the document element.

[0033] It should be noted that the document element obtained by parsing can be one or more, and this application does not make any specific limitation.

[0034] Step S103: parse the target report file to obtain a target chart, read the corresponding chart value source from the worksheet of the target chart according to the chart title of the target chart, fill the chart value source back into the target chart, and redraw the target chart.

[0035] Specifically, through the second parsing interface document.getCharts() of the Java framework, the target report file is parsed to obtain the target chart Chart, and according to the chart title of the target chart, the corresponding chart value source is read from the worksheet of the target chart, and the chart value source is backfilled into the target chart, and the drawing interface chart.plot() is called to redraw the target chart.

[0036] It should be noted that there can be one or more charts obtained through analysis, and this application does not impose any specific limitation.

[0037] Step S104: parse the target report file attachment to obtain the target attachment, clone the internal parameters of the target attachment to obtain the target clone data, obtain external data from the database based on the target clone data, merge the external data with the target clone data to obtain the attachment update data, and write the attachment update data back to the attachment.

[0038] Among them, through the third parsing interface document.getAllEmbeddedParts() of the Java framework, the target report file is parsed to obtain the target attachment, and the internal parameters of the target attachment are cloned to obtain the target clone data, and external data is obtained from the SQLite database according to the target clone data, and the external data is merged with the target clone data to obtain the attachment update data, and the attachment update data is written back to the attachment.

[0039] It should be noted that the target attachments obtained by parsing can be one or more, and this application does not make any specific limitation.

[0040] Step S105: Save the target report file.

[0041] Specifically, the target report file is saved and written to the hard disk.

[0042] It should be noted that through steps S101 to S104 shown in the embodiment of the present application, diversified report output effects can be achieved based on the defined custom template file, and the document elements, charts and attachments of the target report file are parsed and filled in respectively with a modular design concept, which can flexibly respond to different scenarios and needs, improve the scalability of report filling, and enhance the user experience and application value.

[0043] Further, refer to Figure 2 As shown, Figure 2 It is a flowchart of step S102 provided in some embodiments of the present application. The method may include but is not limited to steps S201 to S202.

[0044] Step S201: When the document element is a paragraph element, perform paragraph parsing on the paragraph element and detect whether the content of the paragraph element contains a first placeholder tag. According to the first placeholder tag, read the corresponding document data from the database and replace the first placeholder tag with the document data.

[0045] Specifically, when the document element is a paragraph element XWPFParagraph, the paragraph parsing interface paragraphWrite() of the Java framework is called to perform paragraph parsing on the paragraph element XWPFParagraph, and detect whether there is a first placeholder tag in the content of the paragraph element XWPFParagraph. According to the first placeholder tag, the corresponding document data is read from the SQLite database, and the first placeholder tag is replaced with the document data.

[0046] Step S202: Alternatively, when the document element is a table element, corresponding document data is read from a database according to the content in the table element, and the document data is backfilled into the table element.

[0047] When the document element is a table element XWPFTable, the corresponding document data is read from the SQLite database according to the content in the table element XWPFTable, and the document data is backfilled into the table element XWPFTable.

[0048] Furthermore, the table element includes a plurality of cells, and the document data includes first text data, second text data, and extended data.

[0049] Reference Figure 3 As shown, Figure 3 Other embodiments of the present application provide Figure 2 The method may include but is not limited to steps S301 to S303.

[0050] Step S301: parse the content of each cell and detect whether there is a second placeholder tag in the content of each cell. If so, clear the second placeholder tag in each cell and read the corresponding first text number from the database according to each second placeholder tag.

[0051] Specifically, the content of each cell is parsed, and the content of each cell is checked to see if there is a second placeholder tag (such as DL). If so, the second placeholder tag is cleared in each cell (excess characters are removed), and according to each second placeholder tag, the reading interface Result.getTable (second placeholder tag) is called to read the corresponding first text data from the SQLite database.

[0052] Step S302: Read the filling direction parameter of the table element, and fill the corresponding first text data in each cell in turn according to the filling direction parameter.

[0053] Specifically, the filling direction parameter of the table element is read, and the corresponding first text data is filled into each cell in turn according to the filling direction parameter.

[0054] Step S303: perform paragraph analysis on each cell after filling in data, and detect whether there is a third placeholder tag in the paragraph text of each cell. If so, read the corresponding second text data from the database according to each third placeholder tag, replace each third placeholder tag with the corresponding second text data, and reset the paragraph text of each cell.

[0055] Specifically, paragraph parsing is performed on each cell after being filled with data, and each cell's paragraph text is checked for whether there is a third placeholder tag (such as $#DL). If so, the corresponding second text data is read from the SQLite database according to each third placeholder tag, and each third placeholder tag is replaced with the corresponding second text data, and the paragraph text of each cell is reset.

[0056] In one possible implementation, refer to Figure 4 As shown, Figure 4 Some embodiments of the present application provide Figure 2 The method may include but is not limited to steps S401 to S403.

[0057] Step S401: Read the automatic expansion parameters of the table element, and determine whether the table element needs to be automatically expanded according to the automatic expansion parameters.

[0058] In a possible implementation, an automatic expansion parameter of the table element is read, and based on the automatic expansion parameter, it is determined whether the table element needs to be automatically expanded.

[0059] The automatic extension parameters include an automatic extension judgment field isAutoExtend.

[0060] Step S402: If the table element needs to be automatically expanded, the expansion data is read from the database according to the automatic expansion parameters, and a new row is dynamically inserted into the table element according to the row and column layout of the table element.

[0061] The new row includes a plurality of cells.

[0062] In one possible implementation, if the automatic extension judgment field isAutoExtend==true in the automatic extension parameters, when the table element determines that it needs to be automatically extended, the extension data is read from the SQLite database according to the automatic extension parameters, and a new row is dynamically inserted from the table element according to the row and column layout of the table element.

[0063] Step S403: fill each cell in the new row with extended data in sequence.

[0064] Specifically, each cell in the new row is filled with extended data in turn, and the inserting and filling operations are repeated until all extended data are filled.

[0065] Reference Figure 5 As shown, Figure 5 Some embodiments of the present application provide Figure 3 In the flowchart of step S302, the method may include but is not limited to step S501.

[0066] Step S501: when the filling direction parameter is characterized by row direction, each cell is filled with corresponding first text data in sequence in the row direction.

[0067] In a possible embodiment, when the filling direction parameter is R, where R represents the row direction, each cell is filled with the corresponding first text data in sequence along the row direction.

[0068] Step S502: Alternatively, when the filling direction parameter is characterized by a column direction, each cell is filled with the corresponding first text data in sequence along the column direction.

[0069] In a possible embodiment, when the filling direction parameter is D, and D represents a column direction, each cell is filled with the corresponding first text data in sequence along the column direction.

[0070] Reference Figure 6 As shown, Figure 6 It is a flowchart of reading a chart value source according to a chart title provided by some embodiments of the present application. The method may include but is not limited to step S601.

[0071] Step S601: Read the streaming workbook corresponding to the target chart according to the chart title.

[0072] In a possible embodiment, the streaming workbook SXSSFWorkbook corresponding to the target chart is read according to the chart title.

[0073] Step S602: Convert the flow workbook into an operation workbook, and set the operation workbook into the target chart.

[0074] In a possible embodiment, the streaming workbook SXSSFWorkbook is converted into the operation workbook XSSFWorkbook, and the operation workbook XSSFWorkbook is set to the target chart, so that the target chart can be operated.

[0075] Step S603: Read the data series in the target chart.

[0076] In a possible embodiment, the data series XDDFChartData in the target chart is read.

[0077] Step S604: If reading the data series fails, repairing the drawing area of ​​the target chart.

[0078] In a possible embodiment, if reading the data series fails (for example, an exception IllegalStateException() is thrown), the plotting area fixPlotArea of ​​the target chart is repaired.

[0079] Step S605: If the data series is read successfully, the corresponding data range formula is obtained according to the data series, and according to the data range formula, the corresponding chart value source is read from the worksheet of the target chart, and the chart value source is backfilled into the data series of the target chart.

[0080] In a possible embodiment, if the data series is read successfully, the corresponding data range formula is obtained according to the data series XDDFChartData, and the corresponding chart numerical source (XDDFNumericalDataSource) is read from the worksheet XSSFSheet of the target chart according to the data range formula. <double>), and backfill the chart value source to the data series of the target chart.

[0081] Reference Figure 7 As shown, Figure 7 This is a flowchart of parsing an attachment of a target report file provided by some embodiments of the present application. The method of parsing an attachment of a target report file may include but is not limited to steps S701 to S704.

[0082] Step S701: parse the attachment of the target report file to obtain the first attachment.

[0083] In a possible embodiment, a data series in a target chart is read.

[0084] It should be noted that the file extension of the target report file can be Word, Excel, TXT, etc., and this application does not make any specific limitation.

[0085] Step S702: Determine whether the file extensions of the first attachment and the target report file are consistent.

[0086] In a possible embodiment, when the file extension of the target report file is Word, it is determined whether the file extension of the first attachment is consistent with the file extension Word of the target report file.

[0087] Step S703: If the file extensions of the first attachment and the target report file are inconsistent, the first attachment is determined as the target attachment.

[0088] In a possible embodiment, if the file extensions of the first attachment and the target report file are inconsistent, the first attachment is determined as the target attachment.

[0089] Step S704: Alternatively, if the file extensions of the first attachment and the target report file are consistent, the first attachment will be parsed to obtain the second attachment. If the file extensions of the second attachment and the target report file are consistent, the second attachment will be used as the first attachment again, and the process returns to the step of parsing the first attachment to obtain the second attachment, until the file extensions of the second attachment and the target report file are inconsistent, then the second attachment will be determined as the target attachment.

[0090] In a possible embodiment, if the file extensions of the first attachment and the target report file are consistent, the first attachment will be parsed to obtain the second attachment. If the file extensions of the second attachment and the target report file are consistent, the second attachment will be used as the first attachment again, and the process returns to the step of parsing the first attachment to obtain the second attachment, until the file extensions of the second attachment and the target report file are inconsistent, in which case the second attachment will be determined as the target attachment.

[0091] Further, the target clone data includes the first clone data StylesDatas, the second clone data PictureDatas and the third clone data Result, referring to Figure 8 As shown, Figure 8 This is a flowchart of cloning a target attachment and merging external data with target clone data provided by some embodiments of the present application. The method may include but is not limited to steps S801 to S805.

[0092] Step S801: Clone the style of the target attachment to obtain first cloned data.

[0093] In a possible embodiment, the first clone interface Writer.cloneStyles() in the Java framework is called to clone the style of the target attachment to obtain the first clone data StylesDatas.

[0094] Step S802: Clone the image of the target attachment to obtain second clone data.

[0095] In a possible embodiment, the second clone interface Writer.clonePictureDatas() in the Java framework is called to clone the picture of the target attachment to obtain the second clone data PictureDatas.

[0096] Step S803: clone the data of the source worksheet of the target attachment to obtain third clone data.

[0097] In a possible embodiment, the third cloning interface Writer.cloneSheets() in the Java framework is called to clone the data of the source worksheet of the target attachment to obtain the third clone data Result.

[0098] Step S804: Acquire external data from the database according to the third clone data.

[0099] In a possible embodiment, external data ResultUkList is obtained from the SQLite database according to the third cloned data Result.

[0100] Step S805: Merge the external data, the first clone data, the second clone data, and the third clone data to obtain attachment update data.

[0101] In a possible embodiment, the external data ResultUkList, the first clone data StylesDatas, the second clone data PictureDatas, and the third clone data Result are merged to obtain the attachment update data.

[0102] Reference Fig. 9 As shown, Fig. 9 It is a flowchart of the process of writing attachment update data back to the attachment provided by other embodiments of the present application. The method of writing attachment update data back to the attachment may include but is not limited to steps S901 to S903.

[0103] Step S901: Update the data according to the attachment and build the target workbook of the attachment.

[0104] In a possible embodiment, the target workbook writeWb of the attachment is constructed according to the attachment update data.

[0105] Step S902: Write the target workbook to the memory stream of the attachment.

[0106] In a possible embodiment, the target workbook writeWb is written to the memory stream ByteArrayOutputStream of the attachment.

[0107] Step S903: write the data in the memory stream back to the output stream of the attachment.

[0108] In a possible embodiment, the data in the memory stream ByteArrayOutputStream is written back to the output stream OutputStream of the attachment.

[0109] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above report filling method when executing the computer program. The electronic device can be any smart terminal including a mobile phone, a tablet computer, a car computer, etc.

[0110] See also Fig.10 , Fig.10 : is a schematic diagram of the hardware structure of an electronic device provided in some embodiments of the present application, and the electronic device includes: The processor 1001 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the report filling method provided in the embodiment of the present application; The memory 1002 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1002 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1002, and the processor 1001 calls and executes the report filling method provided in the embodiment of this application; Input / output interface 1003, used to implement information input and output; Communication interface 1004, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.); A bus 1005 , which transmits information between various components of the device (e.g., the processor 1001 , the memory 1002 , the input / output interface 1003 , and the communication interface 1004 ); The processor 1001 , the memory 1002 , the input / output interface 1003 and the communication interface 1004 are connected to each other in communication within the device via the bus 1005 .

[0111] The embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the report filling method provided in the embodiment of the present application is provided.

[0112] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0113] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0114] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0115] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0116] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0117] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0118] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or plural.

[0119] In the several embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0120] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0121] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0122] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-accessible storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0123] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.< / double>

Claims

1. A report filling method, characterized in that: include: In response to a request for report filling, according to the template file path in the request, a custom template file in the database is read, and the custom template file is copied to obtain a target report file; Parsing the target report file to obtain a document element, reading corresponding document data from the database according to the content in the document element, and backfilling the document data into the document element; Performing chart parsing on the target report file to obtain a target chart, reading a corresponding chart value source from a worksheet of the target chart according to a chart title of the target chart, backfilling the chart value source into the target chart, and redrawing the target chart; Parsing the attachment of the target report file to obtain the target attachment, cloning the internal parameters of the target attachment to obtain target clone data, acquiring external data from the database according to the target clone data, merging the external data with the target clone data to obtain attachment update data, and writing the attachment update data back to the attachment; Save the target report file.

2. The report filling method according to claim 1, characterized in that: The reading corresponding document data from the database according to the content in the document element, and backfilling the document data into the document element, includes: When the document element is a paragraph element, performing paragraph parsing on the paragraph element, and detecting whether a first placeholder tag exists in the content of the paragraph element, reading corresponding document data from the database according to the first placeholder tag, and replacing the first placeholder tag with the document data; Alternatively, when the document element is a table element, the corresponding document data is read from the database according to the content in the table element, and the document data is backfilled into the table element.

3. The report filling method according to claim 2, characterized in that: The table element includes a plurality of cells, and the document data includes first text data and second text data; The reading of corresponding document data from the database according to the content in the table element and backfilling the document data into the table element comprises the following steps: Parsing the content of each cell, and detecting whether the content of each cell has a second placeholder tag, and if so, clearing the second placeholder tag in each cell, and reading the corresponding first text data from the database according to each second placeholder tag; Reading a filling direction parameter of the table element, and filling each of the cells with the corresponding first text data in turn according to the filling direction parameter; Paragraph parsing is performed on each of the cells after being filled with data, and each of the paragraph texts of the cells is detected to see whether there is a third placeholder tag. If so, the corresponding second text data is read from the database according to each of the third placeholder tags, and each of the third placeholder tags is replaced with the corresponding second text data, and the paragraph text of each of the cells is reset.

4. The report filling method according to claim 2, characterized in that: The document data also includes extended data, and the reading of corresponding document data from the database according to the content in the table element, and backfilling the document data into the table element, further includes the following steps: Reading the automatic expansion parameter of the table element, and determining whether the table element needs to be automatically expanded according to the automatic expansion parameter; If the table element needs to be automatically expanded, the expansion data is read from the database according to the automatic expansion parameters, and a new row is dynamically inserted from the table element according to the row and column layout of the table element, wherein the new row includes a plurality of cells; The extended data is sequentially filled into each cell in the new row.

5. The report filling method according to claim 3, characterized in that: The step of sequentially filling the cells with the corresponding first text data according to the filling direction parameter includes: When the filling direction parameter is characterized by a row direction, filling the corresponding first text data into each of the cells in sequence according to the row direction; Alternatively, when the filling direction parameter is characterized by a column direction, each of the cells is filled with the corresponding first text data in sequence according to the column direction.

6. The report filling method according to claim 1, characterized in that: The step of reading a corresponding chart value source from a worksheet of the target chart according to the chart title of the target chart, and backfilling the chart value source into the target chart includes: According to the chart title, read the streaming workbook corresponding to the target chart; Convert the streaming workbook into an operation workbook, and set the operation workbook into the target chart; Read the data series in the target chart; If reading the data series fails, repairing the drawing area of ​​the target chart; If the data series is read successfully, the corresponding data range formula is obtained according to the data series, and according to the data range formula, the corresponding chart value source is read from the worksheet of the target chart, and the chart value source is backfilled into the data series of the target chart.

7. The report filling method according to claim 1, characterized in that: The step of parsing the attachment of the target report file to obtain the target attachment includes: Parsing the target report file for attachments to obtain a first attachment; Determining whether the file extensions of the first attachment and the target report file are consistent; If the file extensions of the first attachment and the target report file are inconsistent, determining the first attachment as the target attachment; Alternatively, if the file extensions of the first attachment and the target report file are consistent, the first attachment will be parsed to obtain the second attachment. If the file extensions of the second attachment and the target report file are consistent, the second attachment will be used as the first attachment again, and the process will return to the step of parsing the first attachment to obtain the second attachment, until the file extensions of the second attachment and the target report file are inconsistent, in which case the second attachment will be determined as the target attachment.

8. The report filling method according to claim 1, characterized in that: The target clone data includes first clone data, second clone data and third clone data, the cloning of internal parameters of the target attachment to obtain the target clone data, and acquiring external data from the database according to the target clone data, and merging the external data with the target clone data to obtain attachment update data, including: Cloning the style of the target attachment to obtain the first clone data; Cloning the picture of the target attachment to obtain the second clone data; Cloning the data of the source worksheet of the target attachment to obtain the third cloned data; acquiring the external data from the database according to the third clone data, The external data, the first clone data, the second clone data, and the third clone data are merged to obtain the attachment update data.

9. The report filling method according to claim 8, characterized in that: The attachment update data is written back to the attachment, including: Update data according to the attachment and build a target workbook for the attachment; Write the target workbook to the memory stream of the attachment; Write the data in the memory stream back to the output stream of the attachment.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the report filling method as described in any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Form automatic generation method and system based on form template set

    CN101794280A

  • Method and device for generating report file

    CN108132925A