Report filling method and storage medium thereof
By parsing document elements, charts, and attachments from the reporting system using custom template files, the lack of flexibility in existing reporting systems is resolved, enabling diverse report outputs and improving user experience.
Patent Information
- Application Number
- CN202411993607.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2044-12-31
AI Technical Summary
The existing report system's filling process is limited to a fixed format, lacks flexibility, and cannot meet users' needs for diverse and personalized report templates, nor can it generate customized outputs according to different scenarios.
By using custom template files, the report file's document elements, charts, and attachments are parsed. Data is read from the database and populated according to requirements, enabling modular report filling. It supports the parsing of paragraphs and tables in document elements, the redrawing of charts, and the merging and updating of attachments.
It achieves diverse report output effects, improves the scalability of report filling and user experience, and can flexibly respond to different scenarios and needs.
Smart Images

Figure CN119940326B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of report forms, in particular to a report form filling method and a storage medium thereof. BACKGROUND
[0002] In the process of information management and data processing, various report form systems are important tools for data recording, analysis and display.
[0003] However, the report form filling process of the existing report form system is often limited to fixed formats or single purposes, lacks flexibility, and is difficult to meet the needs of users for diversified and personalized report form templates. In actual applications, different scenarios have various requirements for the structure, content and output effect of the report form. How to generate corresponding customized output according to different input templates has become a key direction for optimizing the report form filling process. SUMMARY
[0004] The main purpose of the embodiments of the present application is to provide a report form filling method and a storage medium thereof. Through a self-defined custom template file, diversified report form output effects are achieved. Moreover, the document elements, charts and attachments of the target report form file are respectively parsed and filled according to the modular design idea, which can flexibly cope with different scenarios and requirements, improve the expandability of the report form filling, and improve the user experience and application value.
[0005] To achieve the above purpose, a first aspect of the embodiments of the present application provides a report form filling method, comprising:
[0006] In response to a request for filling a report form, a custom template file in a database is read according to a custom template file path in the request, and the custom template file is copied to obtain a target report form file;
[0007] The target report form file is parsed to obtain document elements, corresponding document data is read from the database according to the content in the document elements, and the document data is backfilled to the document elements;
[0008] The target report form file is parsed to obtain a target chart, corresponding chart value sources are read from a worksheet of the target chart according to a chart title of the target chart, the chart value sources are backfilled to the target chart, and the target chart is redrawn;
[0009] The target report form file is parsed to obtain a target attachment, internal parameters of the target attachment are cloned to obtain target cloned data, external data is obtained from the database according to the target cloned data, the external data is merged with the target cloned data to obtain attachment update data, and the attachment update data is written back to the attachment;
[0010] The target report form file is saved.
[0011] Further, in some embodiments, reading the corresponding document data from the database according to the content in the document element, and backfilling the document data to the document element, comprises:
[0012] When the document element is a paragraph element, performing paragraph parsing on the paragraph element, and detecting whether the content of the paragraph element contains a first placeholder tag, reading the corresponding document data from the database according to the first placeholder tag, and replacing the first placeholder tag with the document data;
[0013] Or, when the document element is a table element, reading the corresponding document data from the database according to the content in the table element, and backfilling the document data to the table element.
[0014] Further, in some embodiments, the table element comprises a plurality of cells, and the document data comprises first text data and second text data;
[0015] Wherein, reading the corresponding document data from the database according to the content in the table element, and backfilling the document data to the table element, comprises the following steps:
[0016] Performing content parsing on each cell, and respectively detecting whether the content of each cell contains a second placeholder tag, and if so, respectively removing the second placeholder tag in each cell, and respectively reading the corresponding first text data from the database according to each second placeholder tag;
[0017] Reading a filling direction parameter of the table element, and according to the filling direction parameter, sequentially filling each cell with the corresponding first text data;
[0018] Performing paragraph parsing on each cell after filling the data, and respectively detecting whether the paragraph text of each cell contains a third placeholder tag, and if so, respectively reading the corresponding second text data from the database according to each third placeholder tag, and respectively replacing each third placeholder tag with the corresponding second text data, and resetting the paragraph text of each cell.
[0019] Further, in some embodiments, the document data further comprises extension data, and reading the corresponding document data from the database according to the content in the table element, and backfilling the document data to the table element, further comprises the following steps:
[0020] Reading an automatic extension parameter of the table element, and according to the automatic extension parameter, determining whether the table element needs to be automatically extended;
[0021] If the table element needs to be automatically expanded, the expansion data is read from the database according to the automatic expansion parameter, and a new row is dynamically inserted into the table element according to the row and column layout of the table element, wherein the new row includes a plurality of cells;
[0022] The expansion data is sequentially filled into each cell in the new row.
[0023] Further, in some embodiments, according to the filling direction parameter, the corresponding first text data is sequentially filled into each cell, including:
[0024] When the filling direction parameter represents a row direction, the corresponding first text data is sequentially filled into each cell in the row direction;
[0025] Or, when the filling direction parameter represents a column direction, the corresponding first text data is sequentially filled into each cell in the column direction.
[0026] Further, in some embodiments, 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 to the target chart, including:
[0027] According to the chart title, the target chart corresponding streaming workbook is read;
[0028] The streaming workbook is converted into an operation workbook, and the operation workbook is set into the target chart;
[0029] The data series in the target chart is read;
[0030] If the data series fails to be read, the drawing area of the target chart is repaired;
[0031] If the data series is successfully read, 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 to the data series of the target chart.
[0032] Further, in some embodiments, the target report file is parsed to obtain a target attachment, including:
[0033] The target report file is parsed to obtain a first attachment;
[0034] It is judged whether the file extension between the first attachment and the target report file is consistent;
[0035] If the file extension between the first attachment and the target report file is inconsistent, the first attachment is determined as the target attachment;
[0036] Alternatively, if the file extension of the first attachment is the same as that of the target report file, the first attachment will be parsed to obtain the second attachment. If the file extension of the second attachment is the same as that of the target report file, the second attachment will be used as the first attachment again, and the process of parsing the first attachment to obtain the second attachment will be repeated until the file extension of the second attachment is different from that of the target report file. Then the second attachment will be determined as the target attachment.
[0037] Furthermore, in some embodiments, the target clone data includes first clone data, second clone data, and third clone data; internal parameters of the cloned target attachment are used to obtain the target clone data; and external data is obtained from the database based on the target clone data, and the external data is merged with the target clone data to obtain attachment update data, including:
[0038] The pattern of the target attachment is cloned to obtain the first clone data;
[0039] Clone the image attached to the target to obtain the second clone data;
[0040] Clone the data from the source worksheet of the target attachment to obtain the third clone data;
[0041] Based on the third clone data, retrieve external data from the database.
[0042] The external data, the first clone data, the second clone data, and the third clone data are merged to obtain the updated attachment data.
[0043] Furthermore, in some embodiments, the appendix update data is written back to the appendix, including:
[0044] Based on the updated data in the attachments, construct the target workbook for the attachments;
[0045] Write the target workbook to the memory stream of the attachment;
[0046] Write the data in the memory stream back to the attached output stream.
[0047] To achieve the above objectives, a second aspect of the present application provides a storage medium, which is a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the report filling method of the first aspect embodiment described above.
[0048] In the embodiments of the present application, the following beneficial effects are achieved: in the embodiments of the present application, the custom template file path in the request is read according to the request, the custom template file in the database is read, the custom template file is copied to obtain a target report file, then the target report file is parsed to obtain document elements, the corresponding document data is read from the database according to the content in the document elements, and the document data is backfilled to the document elements, then the target report file is parsed to obtain a target chart, the corresponding chart value source is read from the worksheet of the target chart according to the chart title of the target chart, and the chart value source is backfilled to the target chart and the target chart is redrawn, then the target report file is parsed to obtain a target attachment, the internal parameters of the target attachment are cloned to obtain target cloned data, the external data is obtained from the database according to the target cloned data, the external data is merged with the target cloned data to obtain attachment update data, and the attachment update data is written back to the attachment, finally, the target report file is saved, thereby achieving diversified report output effects based on the custom custom template file, and the document elements, the chart and the attachment of the target report file are parsed and filled in respectively based on the modular design idea, different scenes and requirements can be flexibly coped with, the expandability of the report filling is improved, and the user experience and application value are improved. BRIEF DESCRIPTION OF DRAWINGS
[0049] Figure 1 is a flowchart of a report filling method provided by some embodiments of the present application;
[0050] Figure 2 is a flowchart of step S102 provided by some embodiments of the present application;
[0051] Figure 3 is a flowchart of step S202 in the method provided by some embodiments of the present application; Figure 2 is a flowchart of step S202 in the method provided by some embodiments of the present application;
[0052] Figure 4 is a flowchart of step S202 in the method provided by some embodiments of the present application; Figure 2 is a flowchart of step S202 in the method provided by some embodiments of the present application;
[0053] Figure 5 is a flowchart of step S302 in the method provided by some embodiments of the present application; Figure 3 is a flowchart of step S302 in the method provided by some embodiments of the present application;
[0054] Figure 6 is a flowchart of reading the chart value source according to the chart title provided by some embodiments of the present application;
[0055] Figure 7 is a flowchart of parsing the target report file to obtain the target attachment provided by some embodiments of the present application;
[0056] Figure 8 is a flowchart of a process of cloning a target accessory and merging external data with target cloned data provided by some embodiments of the present application;
[0057] Figure 9 is a flowchart of a process of writing back accessory update data to an accessory provided by some embodiments of the present application;
[0058] Figure 10 is a schematic diagram of a hardware structure of an electronic device provided by some embodiments of the present application. DETAILED DESCRIPTION
[0059] In order to make the objects, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application.
[0060] In the description of the present application, it should be understood that the orientation description, such as the orientation or position relationship indicated by up, down, front, back, left, right, etc. is based on the orientation or position relationship shown in the drawings, and is only for the purpose of facilitating the description of the present application and simplifying the description, and therefore cannot be understood as indicating or implying that the device or element indicated must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as limiting the present application.
[0061] It should also be noted that in the description of the present application, the meaning of several is one or more, the meaning of multiple is two or more, greater than, less than, more than, etc. are understood as not including the number, above, below, etc. are understood as including the number. If it is described as first, second, etc. is only for the purpose of distinguishing technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features or the sequence of indicated technical features.
[0062] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0063] In the description of the present application, the description of the terms "one embodiment", "some embodiments", "exemplary embodiment", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In the present specification, the exemplary description of the above terms does not necessarily mean the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0064] The report filling process of the existing report system is often limited to fixed format or single purpose, lacks flexibility, and is difficult to meet the needs of users for diversified and personalized report templates. In actual application, different scenarios have various requirements for the structure, content and output effect of the report. How to generate corresponding customized output according to different input templates becomes the key direction of the optimization of the report filling process.
[0065] Based on this, the application responds to the request of report filling, reads the custom template file in the database according to the custom template file path in the request, copies the custom template file to obtain a target report file, then performs document analysis on the target report file to obtain document elements, reads corresponding document data from the database according to the content in the document elements, and backfills the document data to the document elements, then performs chart analysis on the target report file to obtain a target chart, reads corresponding chart value source from the worksheet of the target chart according to the chart title of the target chart, backfills the chart value source to the target chart, and redraws the target chart, then performs attachment analysis on the target report file to obtain a target attachment, clones the internal parameters of the target attachment to obtain target cloned data, obtains external data from the database according to the target cloned data, merges the external data and the target cloned data to obtain attachment update data, and writes the attachment update data back to the attachment, finally saves the target report file, thereby realizing diversified report output effect based on the custom custom template file, and analyzing and filling the document elements, charts and attachments of the target report file respectively based on the modular design idea, which can flexibly cope with different scenarios and requirements, improves the expandability of the report filling, and improves the user experience and application value.
[0066] The application embodiment provides a report filling method and a storage medium thereof, which are specifically described as follows.
[0067] In a first aspect, a report filling method in the application embodiment is first described. The report filling method is applied to a report filling system, the report filling system includes a Java framework-based server and an SQLite database, and the Java framework-based server is in communication connection with the SQLite database.
[0068] 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 is a lightweight embedded database, which has the advantages of low resource occupation, easy deployment and support for transaction processing, and is very suitable for small and medium-sized data management scenarios. The combination of the two in the report filling method of the application can provide flexible template configuration and data output functions for users while maintaining high performance and low complexity of the report filling system.
[0069] Referring to Figure 1 Figure 1 is a flowchart of a report filling method provided by some embodiments of the application, which can include but is not limited to steps S101 to S105.
[0070] Step S101: In response to a request for report filling, a custom template file in a database is read according to a custom template file path in the request, and the custom template file is copied to obtain a target report file.
[0071] Among them, the server based on the Java framework reads and loads all the tables in all SQLite databases, and when responding to the request for report filling, the custom template file in the SQLite database is read according to the custom template file path in the request through the JDBC interface of the Java framework, and the custom template file is copied to obtain the target report file.
[0072] Step S102: Document parsing is performed on the target report file to obtain document elements, corresponding document data is read from the database according to the content in the document elements, and the document data is backfilled to the document elements.
[0073] Specifically, the target report file is parsed by a first parsing interface document.getElementbyId of the Java framework to obtain document elements IBodyElement, corresponding document data is read from the SQLite database according to the content in the document elements, and the document data is backfilled to the document elements.
[0074] It should be noted that the parsed document elements can be one or more, which is not limited by the application.
[0075] Step S103: Chart parsing is performed on the target report file to obtain a target chart, corresponding chart value sources are read from the worksheet of the target chart according to the chart title of the target chart, the chart value sources are backfilled to the target chart, and the target chart is redrawn.
[0076] Specifically, the target report file is parsed for a chart through a second parsing interface document.getCharts() of the Java framework, a target chart is obtained, corresponding chart value sources are read from a worksheet of the target chart according to a chart title of the target chart, the chart value sources are backfilled to the target chart, and a drawing interface chart.plot() is called to redraw the target chart.
[0077] It should be noted that the parsed chart can be one or more, which is not limited in the present application.
[0078] Step S104: The target report file is parsed for an attachment, a target attachment is obtained, internal parameters of the target attachment are cloned to obtain target cloned data, external data is obtained from a database according to the target cloned data, the external data is merged with the target cloned data to obtain attachment update data, and the attachment update data is written back to the attachment.
[0079] The target report file is parsed for an attachment through a third parsing interface document.getAllEmbeddedParts() of the Java framework, a target attachment is obtained, internal parameters of the target attachment are cloned to obtain target cloned data, external data is obtained from a SQLite database according to the target cloned data, the external data is merged with the target cloned data to obtain attachment update data, and the attachment update data is written back to the attachment.
[0080] It should be noted that the parsed target attachment can be one or more, which is not limited in the present application.
[0081] Step S105: The target report file is saved.
[0082] Specifically, the target report file is saved, and the target report file is written to a hard disk.
[0083] It should be noted that the steps S101 to S104 shown in the embodiments of the present application can further achieve diversified report output effects based on the custom template file, and the document elements, charts and attachments of the target report file are parsed and filled in respectively based on the modular design idea, which can flexibly cope with different scenarios and requirements, improve the expandability of report filling, and improve user experience and application value.
[0084] Further, as shown in Figure 2 Figure 2 is a flowchart of step S102 provided by some embodiments of the present application, and the method can include but is not limited to steps S201 to S202.
[0085] Step S201: When the document element is a paragraph element, performing paragraph parsing on the paragraph element, and detecting whether the content of the paragraph element contains a first placeholder tag, according to the first placeholder tag, reading corresponding document data from the database, and replacing the first placeholder tag with the document data.
[0086] Specifically, when the document element is a paragraph element XWPFParagraph, calling the paragraph parsing interface paragraphWrite() of the Java framework to perform paragraph parsing on the paragraph element XWPFParagraph, and detecting whether the content of the paragraph element XWPFParagraph contains a first placeholder tag, according to the first placeholder tag, reading corresponding document data from the SQLite database, and replacing the first placeholder tag with the document data.
[0087] Step S202: Alternatively, when the document element is a table element, according to the content in the table element, reading corresponding document data from the database, and backfilling the document data to the table element.
[0088] Specifically, when the document element is a table element XWPFTable, according to the content in the table element XWPFTable, reading corresponding document data from the SQLite database, and backfilling the document data to the table element XWPFTable.
[0089] Further, the table element includes a plurality of cells, and the document data includes first text data, second text data, and extension data.
[0090] Referring to Figure 3 , the method provided by some embodiments of the present application Figure 3 is a flowchart of step S202 in the method, and the method can include but is not limited to steps S301 to S303. Figure 2
[0091] Step S301: Performing content parsing on each cell, and respectively detecting whether the content of each cell contains a second placeholder tag, and if so, respectively removing the second placeholder tag in each cell, according to each second placeholder tag, respectively reading corresponding first text data from the database.
[0092] Specifically, performing content parsing on each cell, and respectively detecting whether the content of each cell contains a second placeholder tag (such as DL), and if so, respectively removing the second placeholder tag (removing redundant characters) in each cell, according to each second placeholder tag, calling the reading interface Result.getTable(second placeholder tag) to respectively read corresponding first text data from the SQLite database.
[0093] Step S302: read the filling direction parameter of the table element, and fill the corresponding first text data into each cell in sequence according to the filling direction parameter.
[0094] Specifically, the filling direction parameter of the table element is read, and the corresponding first text data is filled into each cell in sequence according to the filling direction parameter.
[0095] Step S303: perform paragraph analysis on each cell after filling data, and respectively detect whether the paragraph text of each cell contains a third placeholder label, if yes, read the corresponding second text data from the database according to each third placeholder label, and respectively replace each third placeholder label with the corresponding second text data, and reset the paragraph text of each cell.
[0096] Specifically, the paragraph analysis is performed on each cell after filling data, and respectively detects whether the paragraph text of each cell contains a third placeholder label (such as $#DL), if yes, reads the corresponding second text data from the SQLite database according to each third placeholder label, and respectively replaces each third placeholder label with the corresponding second text data, and resets the paragraph text of each cell.
[0097] In a possible implementation, referring to Figure 4 , the method can include but is not limited to steps S401-S403. Figure 4 Figure 2 The flowchart of step S202 in the method provided by some embodiments of the present application can include but is not limited to steps S401-S403.
[0098] Step S401: read the automatic expansion parameter of the table element, and determine whether the table element needs to be automatically expanded according to the automatic expansion parameter.
[0099] In a possible implementation, the automatic expansion parameter of the table element is read, and it is determined whether the table element needs to be automatically expanded according to the automatic expansion parameter.
[0100] The automatic expansion parameter includes an automatic expansion judgment field isAutoExtend.
[0101] Step S402: if the table element needs to be automatically expanded, read the expansion data from the database according to the automatic expansion parameter, and dynamically insert a new row from the table element according to the row and column layout of the table element.
[0102] The new row includes a plurality of cells.
[0103] In one possible implementation, if the auto-extension judgment field isAutoExtend==true in the auto-extension parameter, then when it is determined that a table element needs to be automatically expanded, the extended data is read from the SQLite database according to the auto-extension parameter, and new rows are dynamically inserted from the table element according to the row and column layout of the table element.
[0104] Step S403: Fill each cell in the new row with extended data in sequence.
[0105] Specifically, the extended data is filled into each cell in the new row in turn, and the insertion and filling operations are repeated until all the extended data is filled.
[0106] Reference Figure 5 As shown, Figure 5 This is provided by some embodiments of this application. Figure 3 The flowchart of step S302 is provided. This method may include, but is not limited to, step S501.
[0107] Step S501: When the fill direction parameter is represented as row direction, fill each cell with the corresponding first text data in the row direction in sequence.
[0108] In one possible embodiment, when the fill direction parameter is R, which represents the row direction, the corresponding first text data is filled into each cell sequentially according to the row direction.
[0109] Step S502: Alternatively, when the fill direction parameter is characterized as column direction, fill each cell with the corresponding first text data in the column direction in sequence.
[0110] In one possible embodiment, when the fill direction parameter is D, which represents the column direction, the corresponding first text data is filled into each cell sequentially according to the column direction.
[0111] Reference Figure 6 As shown, Figure 6 This is a flowchart of reading chart value source based on chart title provided in some embodiments of this application. The method may include, but is not limited to, step S601.
[0112] Step S601: Read the streaming workbook corresponding to the target chart based on the chart title.
[0113] In one possible implementation, the streaming workbook SXSSFWorkbook corresponding to the target chart is read based on the chart title.
[0114] Step S602: Convert the flow workbook into an operation workbook and set the operation workbook into the target chart.
[0115] In a possible embodiment, the stream workbook SXSSFWorkbook is converted into the operation workbook XSSFWorkbook, and the operation workbook XSSFWorkbook is set into the target chart, so as to be able to operate the target chart.
[0116] Step S603: reading a data series in the target chart.
[0117] In a possible embodiment, a data series XDDFChartData in the target chart is read.
[0118] Step S604: if the reading of the data series fails, repairing a plot area of the target chart.
[0119] In a possible embodiment, if the reading of the data series fails (for example, an exception IllegalStateException() is thrown), the plot area fixPlotArea of the target chart is repaired.
[0120] Step S605: if the reading of the data series succeeds, acquiring a corresponding data range formula according to the data series, reading a corresponding chart numerical data source from a worksheet of the target chart according to the data range formula, and backfilling the chart numerical data source to the data series of the target chart.
[0121] In a possible embodiment, if the reading of the data series succeeds, a corresponding data range formula is acquired according to the data series XDDFChartData, and a corresponding chart numerical data source (XDDFNumericalDataSource <double>), and backfilling chart numeric sources to data series of a target chart.
[0122] Referring to Figure 7 , Figure 7 is a flowchart of a method for performing attachment analysis on a target report file, which can include but is not limited to steps S701-S704.
[0123] Step S701: performing attachment analysis on the target report file to obtain a first attachment.
[0124] In one possible embodiment, data series in the target chart are read.
[0125] It should be noted that the file extension of the target report file can be Word, Excel, TXT, etc., which is not limited in the present application.
[0126] Step S702: determining whether the file extensions of the first attachment and the target report file are consistent.
[0127] In one 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.
[0128] 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.
[0129] In one 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.
[0130] Step S704: alternatively, if the file extensions of the first attachment and the target report file are consistent, attachment analysis is performed on the first attachment to obtain a second attachment, if the file extensions of the second attachment and the target report file are consistent, the second attachment is re-determined as the first attachment, and the step of performing attachment analysis on the first attachment to obtain the second attachment is returned, until the file extensions of the second attachment and the target report file are inconsistent, and the second attachment is determined as the target attachment.
[0131] In one possible embodiment, if the file extension of the first attachment is consistent with that of the target report file, the first attachment will be parsed to obtain the second attachment. If the file extension of the second attachment is consistent with that of the target report file, the second attachment will be used as the first attachment again, and the process of parsing the first attachment to obtain the second attachment will be repeated until the file extension of the second attachment is inconsistent with that of the target report file, at which point the second attachment will be determined as the target attachment.
[0132] Furthermore, the target clone data includes the first clone data StylesDatas, the second clone data PictureDatas, and the third clone data Result, as referred to... Figure 8 As shown, Figure 8 This is a flowchart of cloning a target attachment and merging external data with the target clone data provided in some embodiments of this application. The method may include, but is not limited to, steps S801 to S805.
[0133] Step S801: Clone the pattern of the target attachment to obtain the first clone data.
[0134] In one possible implementation, the first clone interface Writer.cloneStyles() in the Java framework is called to clone the styles of the target attachment, resulting in first clone data StylesDatas.
[0135] Step S802: Clone the image of the target attachment to obtain the second clone data.
[0136] In one possible implementation, the second clone interface Writer.clonePictureDatas() in the Java framework is called to clone the image of the target attachment and obtain the second clone data PictureDatas.
[0137] Step S803: Clone the data from the source worksheet of the target attachment to obtain the third clone data.
[0138] In one possible implementation, the third-cloning interface Writer.cloneSheets() in the Java framework is called to clone the data of the source worksheet of the target attachment, and obtain the third-cloned data Result.
[0139] Step S804: Obtain external data from the database based on the third clone data.
[0140] In one possible implementation, external data ResultUkList is retrieved from the SQLite database based on the third clone data Result.
[0141] Step S805: merging the external data, the first cloned data, the second cloned data and the third cloned data to obtain the attachment update data.
[0142] In a possible embodiment, the external data ResultUkList, the first cloned data StylesDatas, the second cloned data PictureDatas and the third cloned data Result are merged to obtain the attachment update data.
[0143] Referring to Figure 9 , Figure 9 is a flowchart of a process of writing back the attachment update data to the attachment, and the method of writing back the attachment update data to the attachment can include but is not limited to steps S901 to S903.
[0144] Step S901: constructing a target workbook of the attachment according to the attachment update data.
[0145] In a possible embodiment, a target workbook writeWb of the attachment is constructed according to the attachment update data.
[0146] Step S902: writing the target workbook into a memory stream of the attachment.
[0147] In a possible embodiment, the target workbook writeWb is written into a memory stream ByteArrayOutputStream of the attachment.
[0148] Step S903: re-writing data in the memory stream into an output stream of the attachment.
[0149] In a possible embodiment, data in the memory stream ByteArrayOutputStream is re-written into an output stream OutputStream of the attachment.
[0150] The embodiments of the present application further provide an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the report filling method described above when executing the computer program. The electronic device can be any smart terminal including a mobile phone, a tablet computer, a vehicle-mounted computer and the like.
[0151] Please refer to Figure 10 , Figure 10 is a hardware structure schematic diagram of an electronic device provided by some embodiments of the present application, and the electronic device includes:
[0152] The processor 1001 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits, and is configured to execute related programs to implement the report filling method provided by the embodiments of the present application.
[0153] The memory 1002 can be implemented by a ROM (ReadOnly Memory), a static storage device, a dynamic storage device, or a RAM (Random Access Memory), and the like. The memory 1002 can store an operating system and other application programs, and when the technical solutions provided by the embodiments of the present application are implemented by software or firmware, the related program codes are stored in the memory 1002 and are called and executed by the processor 1001 to implement the report filling method provided by the embodiments of the present application.
[0154] The input / output interface 1003 is configured to implement information input and output.
[0155] The communication interface 1004 is configured to implement the communication interaction between the device and other devices, and can realize the communication through a wired manner (for example, a USB, a network cable, or the like) or a wireless manner (for example, a mobile network, WIFI, Bluetooth, or the like).
[0156] The bus 1005 is configured to transmit information between various components (for example, the processor 1001, the memory 1002, the input / output interface 1003, and the communication interface 1004) of the device.
[0157] The processor 1001, the memory 1002, the input / output interface 1003, and the communication interface 1004 are connected to each other through the bus 1005 to realize the communication connection between the device.
[0158] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program. When the computer program is executed by a processor, the report filling method provided by the embodiments of the present application is implemented.
[0159] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. In addition, the memory can include a high-speed random access memory and can also include a non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state memory device. In some embodiments, the memory can optionally include a memory disposed remotely from the processor, which can be connected to the processor through a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0160] The embodiments described in the embodiments of the present application are used 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 by the embodiments of the present application. Those skilled in the art can know that, with the evolution of technology and the appearance of new application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.
[0161] Those skilled in the art can understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and can include more or fewer steps than shown in the figures, or combine certain steps or different steps.
[0162] The device embodiments described above are only schematic, and the units described as separate components can or can not be physically separate, i.e., can be located in one place or distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments of the present application.
[0163] Those skilled in the art can understand that all or some of the steps in the above disclosed method, the functional modules / units in the system and the device can be implemented as software, firmware, hardware and their appropriate combinations.
[0164] The terms "first", "second", "third", "fourth" and the like used in the specification of the present application and the above-described drawings, if any, are used to distinguish similar objects, and do not necessarily indicate a particular order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in other than the order illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily limit to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0165] It should be understood that, in the application, "at least one" refers to one or more, "multiple" refers to two or more. "And / or", used to describe the association between the associated objects, means that there can be three relationships, for example, "A and / or B" can mean: only A, only B, and A and B exist at the same time, where A, B can be singular or plural. The character " / " generally represents the relationship between the front and rear associated objects as "or". "At least one of the following" or the like refers to any combination of these items, including any combination of single or multiple 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 multiple.
[0166] In several embodiments provided in the application, it should be understood that the disclosed system and method can be implemented in other ways. For example, the system embodiments described above are only illustrative, for example, the division of the above units is only a logical functional division, and actual implementation can have another division, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0167] The units described above as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or they can be distributed on multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0168] In addition, each functional unit in each embodiment of the application can be integrated into a processing unit, or each unit can exist physically, or two or more units can be integrated into one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0169] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer accessible storage medium. Based on such understanding, the technical solutions of the present application, essentially or in other words, the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes multiple instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various program storage media.
[0170] The preferred embodiments of the embodiments of the present application are described above with reference to the accompanying drawings, and are not limited to the scope of the embodiments of the present application. Any modifications, equivalent replacements and improvements made by those skilled in the art without departing from the scope and essence of the embodiments of the present application shall be within the scope of the embodiments of the present application.< / double>
Claims
1. A report filling method characterized by, The method comprises the following steps: reading a custom template file in a database according to a template file path in the request, and copying the custom template file to obtain a target report file in response to a request for filling a report; performing document analysis on the target report file to obtain document elements, reading corresponding document data from the database according to the content in the document elements, and backfilling the document data into the document elements; performing chart analysis on the target report file to obtain a target chart, reading corresponding chart value sources from a worksheet of the target chart according to a chart title of the target chart, backfilling the chart value sources into the target chart, and redrawing the target chart; performing attachment analysis on the target report file to obtain a target attachment, cloning internal parameters of the target attachment to obtain target cloned data, obtaining external data from the database according to the target cloned data, merging the external data and the target cloned data to obtain attachment update data, and writing the attachment update data back to the target attachment; saving the target report file; wherein the attachment analysis on the target report file to obtain a target attachment comprises: performing attachment analysis on the target report file 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, the first attachment is determined as the target attachment; or, if the file extensions of the first attachment and the target report file are consistent, performing attachment analysis on the first attachment to obtain a second attachment, if the file extensions of the second attachment and the target report file are consistent, the second attachment is re-used as the first attachment, and the step of performing attachment analysis on the first attachment to obtain a second attachment is returned until the file extensions of the second attachment and the target report file are inconsistent, and the second attachment is determined as the target attachment.
2. The report filling method of claim 1, wherein, The reading of the corresponding document data from the database according to the content in the document elements, and the backfilling of the document data into the document elements, comprises: when the document element is a paragraph element, performing paragraph analysis on the paragraph element, detecting whether the content of the paragraph element contains a first placeholder label, reading corresponding document data from the database according to the first placeholder label, and replacing the first placeholder label with the document data; or, when the document element is a table element, reading corresponding document data from the database according to the content in the table element, and backfilling the document data into the table element.
3. The report filling method of claim 2, wherein, The table element comprises a plurality of cells, and the document data comprises first text data and second text data. The reading of the corresponding document data from the database according to the content in the table element, and the backfilling of the document data into the table element, comprises the following steps: The content of each cell is parsed, and whether the content of each cell contains a second placeholder label is detected, and if so, the second placeholder label is removed from each cell. According to the second placeholder label, the corresponding first text data is read from the database. The filling direction parameter of the table element is read, and according to the filling direction parameter, the corresponding first text data is sequentially filled into each cell. The paragraph of each filled cell is parsed, and whether the paragraph text of each cell contains a third placeholder label is detected. If so, according to the third placeholder label, the corresponding second text data is read from the database, and each third placeholder label is replaced by the corresponding second text data, and the paragraph text of each cell is reset.
4. The report filling method of claim 2, wherein, The document data also includes extension data. According to the content in the table element, the corresponding document data is read from the database, and the table element is backfilled with the document data. The steps include: Read the automatic expansion parameter of the table element, and determine whether the table element needs to be automatically expanded according to the automatic expansion parameter; If the table element needs to be automatically expanded, read the extension data from the database according to the automatic expansion parameter, and dynamically insert a new row into the table element according to the row and column layout of the table element, wherein the new row includes multiple cells; The extension data is sequentially filled into each cell in the new row.
5. The report filling method of claim 3, wherein, According to the filling direction parameter, the corresponding first text data is sequentially filled into each cell, which includes: When the filling direction parameter represents a row direction, the corresponding first text data is sequentially filled into each cell in the row direction; Or, when the filling direction parameter represents a column direction, the corresponding first text data is sequentially filled into each cell in the column direction.
6. The report filling method of claim 1, wherein, 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, which includes: According to the chart title, read the corresponding streaming workbook of 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 the data series fails to read, repair the drawing area of the target chart; If the data series is successfully read, 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.
7. The report filling method of claim 1, wherein, The target clone data includes first clone data, second clone data and third clone data, the internal parameters of the target attachment are cloned to obtain the target clone data, 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 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 clone data; According to the third clone data, the external data is obtained from the database, The external data, the first clone data, the second clone data, the third clone data are merged to obtain the attachment update data.
8. The report filling method of claim 7, wherein, The attachment update data is written back to the target attachment, including: According to the attachment update data, a target workbook of the target attachment is constructed; The target workbook is written into the memory stream of the target attachment; The data in the memory stream is re-written back to the output stream of the target attachment.
9. A computer readable storage medium, the storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to realize the report filling method of any one of claims 1 to 8.
Citation Information
Patent Citations
Form automatic generation method and system based on form template set
CN101794280A
Method and device for generating report file
CN108132925A