A method, system, device, and medium for outputting data from multiple data sources in a report.

By automatically assigning data source column widths and preprocessing data source field meanings, the problem of inconsistent data source table widths is solved, enabling rapid display of data from multiple data sources in the same report, and improving data processing efficiency.

CN113656403BActive Publication Date: 2024-10-15JINAN INSPUR DATA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110841083.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-23
Publication Date
2024-10-15
Estimated Expiration
2041-07-23

AI Technical Summary

Technical Problem

When outputting tables from different data sources in the same report, due to the unequal number of fields, the table widths are inconsistent, and it is difficult to quickly output content from multiple data sources.

Method used

By obtaining the number of fields from each data source, determine the maximum number of fields and automatically allocate the width of each column to make it equal, preprocess the data to obtain the meaning of the fields, and define the header and table column widths to be consistent, and traverse the output header and table content.

Benefits of technology

This enables data from different data sources to be quickly and effectively displayed in the same report without special processing, improving data processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113656403B_ABST
    Figure CN113656403B_ABST
Patent Text Reader

Abstract

The present invention proposes a method, system, device and medium for outputting data from multiple data sources in a report, the method comprising: obtaining the number of fields of each data source and determining the maximum number of fields; automatically allocating the width of each column of each data source according to the maximum number of fields, and making the width of each column the same; preprocessing the data in each data source according to the structure of the data in each data source and obtaining the meaning of each data source field; defining the width of each column of the header and table for the preprocessed data according to the meaning of each data source field; traversing the data in each data source and outputting the header and table content in sequence through the report. Based on the method, a system, device and medium for outputting data from multiple data sources in a report are also proposed. The present invention preprocesses the data of multiple data sources, sets the width of each column of the header and table data, writes the data of each data source in sequence, and quickly and effectively displays them in the same report without special processing, thereby improving the efficiency of data processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of data processing, and in particular relates to a method, system, device and medium for outputting data from multiple data sources in a report. Background Art

[0002] A data source is a database or database server used by a database application. As the name implies, a data source is the source of data, a device or raw media that provides some required data. All the information for establishing a database connection is stored in the data source. Just like you can find a file in the file system by specifying the file name, you can find the corresponding database connection by providing the correct data source name.

[0003] When outputting tables with different information in the same report, due to the different number of fields in the data source, when each field occupies a column of the same width, the total width of each table may be different, making the entire report look uneven. In addition, due to the different contents of each data source, how to quickly output the content of the data source to the table is also a tricky problem. Summary of the invention

[0004] In order to solve the above technical problems, the present invention proposes a method, system, device and medium for outputting data from multiple data sources in a report, pre-processing the data from multiple data sources, setting the width of each column of the header and table data. Then, the common method of writing the report is called to write the data from each data source in turn. In this way, data from different data sources can be quickly and effectively displayed in the same report without special processing.

[0005] To achieve the above object, the present invention adopts the following technical solutions:

[0006] A method for outputting data from multiple data sources in a report comprises the following steps:

[0007] The number of fields of each data source is obtained to determine the maximum number of fields; the width of each column of each data source is automatically allocated according to the maximum number of fields, and the width of each column is made the same; the maximum number of fields is a multiple of the number of fields of each data source;

[0008] According to the structure of the data in each data source, pre-process the data in each data source to obtain the meaning of each data source field;

[0009] According to the meaning of each data source field, define the width of the header and each column of the table for the preprocessed data; make the width of each column of the table corresponding to the header the same as the width of each column in each row of the table content;

[0010] Traverse the data in each data source and output the table header and table content in sequence through the report.

[0011] Furthermore, the process of obtaining the number of fields of each data source, determining the maximum number of fields, and automatically allocating the width of each column of each data source according to the maximum number of fields, and making the widths of each column the same includes:

[0012] Get the number of fields of each data source and determine the maximum number of fields max. If max is a multiple of the number of fields of each data source, the maximum number of columns n is equal to max; otherwise, set the maximum number of columns n to a multiple of any integer greater than or equal to max so that the widths of each column are the same.

[0013] Further, the structure of the data includes an attribute table and a list table;

[0014] The attribute table has a header that occupies one row, and the values ​​corresponding to each column of the header that occupies one row;

[0015] The list table has a header that occupies one line, and each line below the header contains list data.

[0016] Furthermore, preprocessing the data in each data source according to the structure of the data in each data source to obtain the meaning of each data source field includes:

[0017] If the attribute table is output, it is processed into a Map object format to obtain the meaning of each data source field;

[0018] If the output is a list table, it is processed into an array of Map objects to obtain the meaning of each data source field;

[0019] Furthermore, the process of processing into Map object format is: defining four attributes of the header object array: key, display, value and length; the key is the column identifier; the display is the display content of the column; the value is the value corresponding to the field; the length is the multiple of the number of unit columns occupied by the column;

[0020] The process of processing the array form of the Map object is: define three attributes of the header object array: key, display and length; where key is the column identifier; display is the display content of the column; and length is a multiple of the number of unit columns occupied by the column.

[0021] Furthermore, the process of defining the width of the header and each column of the table for the preprocessed data according to the meaning of each data source field is as follows:

[0022] For the attribute table, merge two maps and set the width of each column; each Map object in the merged content contains the information of the table header and the columns in the table content; display is the report content under the table header, and value is the report content of the columns in the table;

[0023] For a list table, first set the content and width of each column in the table header; then set the width and content for each row of table data; for each row of data, traverse the header array to find the corresponding width.

[0024] Furthermore, the process of traversing the data in each data source and outputting the table header and table content in sequence through the report is as follows:

[0025] Traverse the array twice for the attribute table, and output the table header and two rows of table contents in turn;

[0026] Traverse each data in the list table in turn, and output the table header and multiple rows of table content.

[0027] A system for outputting data from multiple data sources in a report, comprising an acquisition module, a preprocessing module, a definition module and an output module;

[0028] The acquisition module is used to acquire the number of fields of each data source and determine the maximum number of fields; automatically allocate the width of each column of each data source according to the maximum number of fields, and make the width of each column the same; the maximum number of fields is a multiple of the number of fields of each data source;

[0029] The preprocessing module is used to preprocess the data in each data source according to the structure of the data in each data source, and obtain the meaning of each data source field;

[0030] The definition module is used to define the width of the table header and each column of the table for the preprocessed data according to the meaning of each data source field; so that the width of each column of the table corresponding to the table header is the same as the width of each column in each row of the table content;

[0031] The output module is used to traverse the data in each data source and output the table header and table content in sequence through reports.

[0032] A device comprising:

[0033] Memory for storing computer programs;

[0034] A processor is used to implement the method steps described when executing the computer program.

[0035] A readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described are implemented.

[0036] The effects provided in the content of the invention are only the effects of the embodiments, not all the effects of the invention. One of the above technical solutions has the following advantages or beneficial effects:

[0037] The present invention proposes a method, system, device and medium for outputting data from multiple data sources in a report. The method comprises: obtaining the number of fields of each data source and determining the maximum number of fields; automatically allocating the width of each column of each data source according to the maximum number of fields, and making the width of each column the same; the maximum number of fields is a multiple of the number of fields of each data source; preprocessing the data in each data source according to the structure of the data in each data source to obtain the meaning of each data source field; defining the width of each column of the header and the table for the preprocessed data according to the meaning of each data source field; making the width of each column of the table corresponding to the header the same as the width of each column in each row of the table content; traversing the data in each data source, and outputting the header and the table content in turn through the report. Based on the problems existing in the prior art, the present invention preprocesses the data of multiple data sources and sets the width of each column of the header and the table data. Then, the public method of writing the report is called to write the data of each data source in turn. In this way, data from different data sources can be quickly and effectively displayed in the same report without special processing, and the method improves the efficiency of data processing.

[0038] Based on a method for outputting data from multiple data sources in a report, the present invention also proposes a system, device and storage medium for outputting data from multiple data sources in a report, which also have the functions of the above method and are not described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] like Figure 1 This is a flow chart of a method for outputting data from multiple data sources in a report in Embodiment 1 of the present invention;

[0040] like Figure 2 This is a schematic diagram of a system for outputting data from multiple data sources in a report according to Embodiment 2 of the present invention. DETAILED DESCRIPTION

[0041] In order to clearly illustrate the technical features of the present solution, the present invention is described in detail below through specific implementation methods and in conjunction with the accompanying drawings. The disclosure below provides many different embodiments or examples for realizing different structures of the present invention. In order to simplify the disclosure of the present invention, the components and settings of specific examples are described below. In addition, the present invention may repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed. It should be noted that the components illustrated in the accompanying drawings are not necessarily drawn to scale. The present invention omits the description of known components and processing techniques and processes to avoid unnecessary limitations on the present invention.

[0042] Example 1

[0043] Embodiment 1 of the present invention provides a method for outputting data from multiple data sources in a report. Figure 1 A flow chart of a method for outputting data from multiple data sources in a report according to Embodiment 1 of the present invention is provided.

[0044] In step S101, the number of fields of each data source is obtained to determine the maximum number of fields; the width of each column of each data source is automatically allocated according to the maximum number of fields, and the width of each column is made the same; the maximum number of fields is a multiple of the number of fields of each data source.

[0045] In this step, the number of fields of each data source is obtained, and the maximum number of fields max is determined. If max is a multiple of the number of fields of each data source, the maximum number of columns n is equal to max; otherwise, the maximum number of columns n is set to a multiple of any integer greater than or equal to max; so that the width of each column is the same. That is, if max = 11, the maximum number of columns n is set to 12; if the maximum number of columns n is a multiple of the number of fields m of a data source, the length of the data source is automatically assigned to n / m, otherwise the length of each field can be manually set in the following steps.

[0046] Set the total number of columns occupied by each table to be equal. The number of columns occupied by each column of each table should be as equal as possible. That is, the width of each column is equal to the width of N columns. For example, for a table with about ten fields, we can define the total number of columns to be 12, which is a multiple of 3 and 4, 2 and 6. When a table has 6 fields, we define each column to occupy 2 columns; when a table has 4 fields, we define each column to occupy 3 columns. When a table has 5 fields, we can set the length of 3 columns to 2 and the length of the remaining 2 columns to 3, so that the total number is also 12.

[0047] In step S102, the width of each column is set according to the result of the process in step S101.

[0048] In step S103, the data in each data source is preprocessed according to the structure of the data in each data source to obtain the meaning of each data source field;

[0049] First, determine whether the data structure is an attribute table or a list table. In an attribute table, the header occupies one row, and the values ​​corresponding to each column of the header occupies one row; in a list table, the header occupies one row, and each row below the header contains the data of the list.

[0050] In step S104, if the output is an attribute table, it is processed into a Map object format.

[0051] That is, the format is like {name:class1,num:20}, which gets the meaning of each data source field {name:class name, num:class number}.

[0052] In step S105, for the attribute table, first define the header object array, and the header defines four attributes: key, display, value, and length. The key represents the identifier of the column, which is distinguished from other columns; the key value here is consistent with the definition of the field of the data source. Display is the display content of the column; value is the value corresponding to the field, and length is the multiple of the number of unit columns occupied by the column. In this way, by traversing the array twice, the entire table can be output.

[0053] In step S106, the length of the header and each column of the table is then set for the preprocessed data. For the attribute table, two maps are merged and the width of each column is set. Each Map object in the merged content contains the information of the column of the header and the table content. Display is the report content of the column of the header, and value is the report content of the column in the table.

[0054] [{key:name,display:class name,value:class1,length:2},{key:num,display:class number,value:20,length:2}].

[0055] In step 107, if the output is a list table, it is processed into an array form of Map objects.

[0056] That is, [{name:zhangsan,age:11,level:good},{name:lisi,age:12,level:bad}]. And get the meaning of each data source field {name:student name, age:age, level:score level}.

[0057] In step S108, for the list table, first define the header object array, and the header defines three attributes: key, display, and length. The key represents the identifier of the column, which is distinguished from other columns; the key value here is consistent with the definition of the field of the data source. Display is the display content of the column, and length is the multiple of the number of unit columns occupied by the column. Then loop through the data source, and define three attributes key, value, and length for each row of the data, where key and length are consistent with each column of the header, and value is the value of the field corresponding to a column of the row.

[0058] In step S109, for the list table, firstly, the content and width of each column are set for the table header.

[0059] [{key:name,display:student name,length:2},{key:age,display:age,length:1},{key:level,display:grade,length:3}]; Then set the width and content for each row of the table data. For each row of data, traverse the header array and find the corresponding length. The output array is as follows:

[0060] [{key:name,value:zhangsan,length:2},{key:age,value:11,length:1};

[0061] {key:level,value:good,length:3}];

[0062] [{key:name,value:lisi,length:2},{key:age,value:12,length:1};

[0063] {key:level,value:bad,length:3}].

[0064] In this application, by defining the key values ​​of the header and table data content according to the field attributes of each data source, and defining the length of each column, when outputting, you only need to traverse the array, draw the width of the column according to the length value, and fill the header and table content according to the display and value values. That is, pre-process the data source, and then call the public method to output it to the same report.

[0065] The present invention pre-processes the data of multiple data sources, sets the width of each column of the table header and table data, and then calls the common method of writing the report to write the data of each data source in turn. In this way, the data of different data sources can be quickly and effectively displayed in the same report without special processing.

[0066] Example 2

[0067] Based on the method for outputting data from multiple data sources in a report proposed in Example 1 of the present invention, Example 2 of the present invention further proposes a system for outputting data from multiple data sources in a report. The system includes an acquisition module, a preprocessing module, a definition module, and an output module;

[0068] The acquisition module is used to acquire the number of fields of each data source and determine the maximum number of fields; automatically allocate the width of each column of each data source according to the maximum number of fields, and make the width of each column the same; the maximum number of fields is a multiple of the number of fields of each data source;

[0069] The preprocessing module is used to preprocess the data in each data source according to the structure of the data in each data source, and obtain the meaning of each data source field;

[0070] The definition module is used to define the width of the header and each column of the table for the preprocessed data according to the meaning of each data source field; the width of each column of the table corresponding to the header is made the same as the width of each column in each row of the table content;

[0071] The output module is used to traverse the data in each data source and output the table header and table content in sequence through the report.

[0072] The process implemented by the acquisition module is as follows: obtain the number of fields of each data source, determine the maximum number of fields max, if max is a multiple of the number of fields of each data source, then the maximum number of columns n is equal to max; otherwise, the maximum number of columns n is set to a multiple of any integer greater than or equal to max; so that the width of each column is the same. That is, if max = 11, the maximum number of columns n is set to 12; if the maximum number of columns n is a multiple of the number of fields m of a data source, then the length of the data source is automatically assigned to n / m, otherwise the length of each field can be manually set in the following steps.

[0073] The processing process of the preprocessing module is as follows: first distinguish the structure of the data, where the data structure includes an attribute table and a list table; the attribute table occupies one row for the header, and each column of the header occupies one row for the value corresponding to it; the list table occupies one row for the header, and each row below the header is the data of the list.

[0074] If the attribute table is output, it is processed into a Map object format to obtain the meaning of each data source field;

[0075] If the output is a list table, it is processed into an array of Map objects to obtain the meaning of each data source field;

[0076] Define the four attributes of the header object array: key, display, value, and length; the key is the column identifier; the display is the display content of the column; the value is the value corresponding to the field; and the length is the multiple of the number of unit columns occupied by the column;

[0077] The process of processing the array form of the Map object is: define three attributes of the header object array: key, display, and length; where key is the column identifier; the display is the display content of the column; and length is a multiple of the number of unit columns occupied by the column.

[0078] The process of module processing is defined as follows: for attribute tables, merge two maps and set the width of each column; each Map object in the merged content contains information about the columns in the table header and table content; display is the report content below the header, and value is the report content of the column in the table; for list tables, first set the content and width of each column in the header; then set the width and content for each row of table data; for each row of data, traverse the header array and find the corresponding width

[0079] The processing process of the output module is: traverse the array twice for the attribute table, and output the table header and two rows of table content in turn; traverse each data in the list table in turn, and output the table header and multiple rows of table content.

[0080] Example 3

[0081] The present invention also proposes a device, comprising:

[0082] Memory for storing computer programs;

[0083] The processor is used to implement the following method steps when executing the computer program:

[0084] In step S101, the number of fields of each data source is obtained to determine the maximum number of fields; the width of each column of each data source is automatically allocated according to the maximum number of fields, and the width of each column is made the same; the maximum number of fields is a multiple of the number of fields of each data source.

[0085] In this step, the number of fields of each data source is obtained, and the maximum number of fields max is determined. If max is a multiple of the number of fields of each data source, the maximum number of columns n is equal to max; otherwise, the maximum number of columns n is set to a multiple of any integer greater than or equal to max; so that the width of each column is the same. That is, if max = 11, the maximum number of columns n is set to 12; if the maximum number of columns n is a multiple of the number of fields m of a data source, the length of the data source is automatically assigned to n / m, otherwise the length of each field can be manually set in the following steps.

[0086] Set the total number of columns occupied by each table to be equal. The number of columns occupied by each column of each table should be as equal as possible. That is, the width of each column is equal to the width of N columns. For example, for a table with about ten fields, we can define the total number of columns to be 12, which is a multiple of 3 and 4, 2 and 6. When a table has 6 fields, we define each column to occupy 2 columns; when a table has 4 fields, we define each column to occupy 3 columns. When a table has 5 fields, we can set the length of 3 columns to 2 and the length of the remaining 2 columns to 3, so that the total number is also 12.

[0087] In step S102, the width of each column is set according to the result of the process in step S101.

[0088] In step S103, the data in each data source is preprocessed according to the structure of the data in each data source to obtain the meaning of each data source field;

[0089] First, determine whether the data structure is an attribute table or a list table. In an attribute table, the header occupies one row, and the values ​​corresponding to each column of the header occupies one row; in a list table, the header occupies one row, and each row below the header contains the data of the list.

[0090] In step S104, if the output is an attribute table, it is processed into a Map object format.

[0091] That is, the format is like {name:class1,num:20}, which gets the meaning of each data source field {name:class name, num:class number}.

[0092] In step S105, for the attribute table, first define the header object array, and the header defines four attributes: key, display, value, and length. The key represents the identifier of the column, which is distinguished from other columns; the key value here is consistent with the definition of the field of the data source. Display is the display content of the column; value is the value corresponding to the field, and length is the multiple of the number of unit columns occupied by the column. In this way, by traversing the array twice, the entire table can be output.

[0093] In step S106, the length of the header and each column of the table is then set for the preprocessed data. For the attribute table, two maps are merged and the width of each column is set. Each Map object in the merged content contains the information of the column of the header and the table content. Display is the report content of the column of the header, and value is the report content of the column in the table.

[0094] [{key:name,display:class name,value:class1,length:2},{key:num,display:class number,value:20,length:2}]

[0095] In step 107, if the output is a list table, it is processed into an array form of Map objects.

[0096] That is, [{name:zhangsan,age:11,level:good},{name:lisi,age:12,level:bad}]. And get the meaning of each data source field {name:student name, age:age, level:score level}.

[0097] In step S108, for the list table, first define the header object array, and the header defines three attributes: key, display, and length. The key represents the identifier of the column, which is distinguished from other columns; the key value here is consistent with the definition of the field of the data source. Display is the display content of the column, and length is the multiple of the number of unit columns occupied by the column. Then loop through the data source, and define three attributes key, value, and length for each row of the data, where key and length are consistent with each column of the header, and value is the value of the field corresponding to a column of the row.

[0098] In step S109, for the list table, firstly, the content and width of each column are set for the table header.

[0099] [{key:name,display:student name,length:2},{key:age,display:age,length:1},{key:level,display:score level,length:3}]; Then set the width and content for each row of the table data. For each row of data, traverse the header array and find the corresponding length. The output array is as follows

[0100] [{key:name,value:zhangsan,length:2},{key:age,value:11,length:1};

[0101] {key:level,value:good,length:3}];

[0102] [{key:name,value:lisi,length:2},{key:age,value:12,length:1};

[0103] {key:level,value:bad,length:3}].

[0104] In this application, by defining the key values ​​of the header and table data content according to the field attributes of each data source, and defining the length of each column, when outputting, you only need to traverse the array, draw the width of the column according to the length value, and fill the header and table content according to the display and value values. That is, pre-process the data source, and then call the public method to output it to the same report.

[0105] The present invention pre-processes the data of multiple data sources, sets the width of each column of the table header and table data, and then calls the common method of writing the report to write the data of each data source in turn. In this way, the data of different data sources can be quickly and effectively displayed in the same report without special processing.

[0106] It should be noted that the technical solution of the present invention also provides an electronic device, including: a communication interface, which can exchange information with other devices such as network devices; a processor, connected to the communication interface to realize information exchange with other devices, and used to execute a method of outputting multi-data source data in a report provided by one or more of the above technical solutions when running a computer program, and the computer program is stored in a memory. Of course, in actual application, the various components in the electronic device are coupled together through a bus system. It can be understood that the bus system is used to realize the connection and communication between these components. In addition to the data bus, the bus system also includes a power bus, a control bus and a status signal bus. The memory in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of these data include: any computer program for operating on an electronic device. It can be understood that the memory can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache.By way of exemplary but not limiting explanation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), direct memory bus random access memory (DRRAM). The memory described in the embodiment of the present application is intended to include but is not limited to these and any other suitable types of memory. The method disclosed in the above embodiment of the present application can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software. The above processor can be a general-purpose processor, a DSP (Digital Signal Processing, which refers to a chip that can implement digital signal processing technology), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor, etc. In conjunction with the steps of the method disclosed in the embodiments of the present application, it can be directly embodied as a hardware decoding processor to perform, or it can be performed by a combination of hardware and software modules in a decoding processor. The software module can be located in a storage medium, which is located in a memory, and the processor reads the program in the memory and completes the steps of the above method in combination with its hardware. When the processor executes the program, the corresponding process in each method of the embodiment of the present application is implemented, and for the sake of brevity, it is not repeated here.

[0107] Example 4

[0108] The present invention also provides a readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following method steps are implemented:

[0109] In step S101, the number of fields of each data source is obtained to determine the maximum number of fields; the width of each column of each data source is automatically allocated according to the maximum number of fields, and the width of each column is made the same; the maximum number of fields is a multiple of the number of fields of each data source.

[0110] In this step, the number of fields of each data source is obtained, and the maximum number of fields max is determined. If max is a multiple of the number of fields of each data source, the maximum number of columns n is equal to max; otherwise, the maximum number of columns n is set to a multiple of any integer greater than or equal to max; so that the width of each column is the same. That is, if max = 11, the maximum number of columns n is set to 12; if the maximum number of columns n is a multiple of the number of fields m of a data source, the length of the data source is automatically assigned to n / m, otherwise the length of each field can be manually set in the following steps.

[0111] Set the total number of columns occupied by each table to be equal. The number of columns occupied by each column of each table should be as equal as possible. That is, the width of each column is equal to the width of N columns. For example, for a table with about ten fields, we can define the total number of columns to be 12, which is a multiple of 3 and 4, 2 and 6. When a table has 6 fields, we define each column to occupy 2 columns; when a table has 4 fields, we define each column to occupy 3 columns. When a table has 5 fields, we can set the length of 3 columns to 2 and the length of the remaining 2 columns to 3, so that the total number is also 12.

[0112] In step S102, the width of each column is set according to the result of the process in step S101.

[0113] In step S103, the data in each data source is preprocessed according to the structure of the data in each data source to obtain the meaning of each data source field;

[0114] First, determine whether the data structure is an attribute table or a list table. In an attribute table, the header occupies one row, and the values ​​corresponding to each column of the header occupies one row; in a list table, the header occupies one row, and each row below the header contains the data of the list.

[0115] In step S104, if the output is an attribute table, it is processed into a Map object format.

[0116] That is, the format is like {name:class1,num:20}, which gets the meaning of each data source field {name:class name, num:class number}.

[0117] In step S105, for the attribute table, first define the header object array, and the header defines four attributes: key, display, value, and length. The key represents the identifier of the column, which is distinguished from other columns; the key value here is consistent with the definition of the field of the data source. Display is the display content of the column; value is the value corresponding to the field, and length is the multiple of the number of unit columns occupied by the column. In this way, by traversing the array twice, the entire table can be output.

[0118] In step S106, the length of the header and each column of the table is then set for the preprocessed data. For the attribute table, two maps are merged and the width of each column is set. Each Map object in the merged content contains the information of the column of the header and the table content. Display is the report content of the column of the header, and value is the report content of the column in the table.

[0119] [{key:name,display:class name,value:class1,length:2},{key:num,display:class number,value:20,length:2}]

[0120] In step 107, if the output is a list table, it is processed into an array form of Map objects.

[0121] That is, [{name:zhangsan,age:11,level:good},{name:lisi,age:12,level:bad}]. And get the meaning of each data source field {name:student name, age:age, level:score level}.

[0122] In step S108, for the list table, first define the header object array, and the header defines three attributes: key, display, and length. The key represents the identifier of the column, which is distinguished from other columns; the key value here is consistent with the definition of the field of the data source. Display is the display content of the column, and length is the multiple of the number of unit columns occupied by the column. Then loop through the data source, and define three attributes key, value, and length for each row of the data, where key and length are consistent with each column of the header, and value is the value of the field corresponding to a column of the row.

[0123] In step S109, for the list table, firstly, the content and width of each column are set for the table header.

[0124] [{key:name,display:student name,length:2},{key:age,display:age,length:1},{key:level,display:score level,length:3}]; Then set the width and content for each row of the table data. For each row of data, traverse the header array and find the corresponding length. The output array is as follows

[0125] [{key:name,value:zhangsan,length:2},{key:age,value:11,length:1};

[0126] {key:level,value:good,length:3}];

[0127] [{key:name,value:lisi,length:2},{key:age,value:12,length:1};

[0128] {key:level,value:bad,length:3}].

[0129] In this application, by defining the key values ​​of the header and table data content according to the field attributes of each data source, and defining the length of each column, when outputting, you only need to traverse the array, draw the width of the column according to the length value, and fill the header and table content according to the display and value values. That is, pre-process the data source, and then call the public method to output it to the same report.

[0130] The present invention pre-processes the data of multiple data sources, sets the width of each column of the table header and table data, and then calls the common method of writing the report to write the data of each data source in turn. In this way, the data of different data sources can be quickly and effectively displayed in the same report without special processing.

[0131] For the description of the relevant parts of the device and storage medium for outputting data from multiple data sources in a report provided in an embodiment of the present application, please refer to the detailed description of the corresponding parts of the method for outputting data from multiple data sources in a report provided in Example 1 of the present application, and will not be repeated here.

[0132] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment that includes a series of elements are inherent to the elements. In the absence of more restrictions, the elements limited by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or equipment that includes the elements. In addition, the above-mentioned technical solution provided in the embodiment of the present application is consistent with the corresponding technical solution in the prior art in principle, and the part is not described in detail, so as not to repeat too much.

[0133] Although the above describes the specific implementation of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. For those skilled in the art, other different forms of modifications or deformations can be made on the basis of the above description. It is not necessary and impossible to list all the implementation methods here. On the basis of the technical solution of the present invention, various modifications or deformations that can be made by those skilled in the art without creative work are still within the scope of protection of the present invention.

Claims

1. A method for outputting data from multiple data sources in a report, characterized in that: The following steps are involved: The number of fields of each data source is obtained, and the maximum number of fields is determined; the width of each column of each data source is automatically allocated according to the maximum number of fields, and the width of each column is made the same; the maximum number of fields is a multiple of the number of fields of each data source; the number of fields of each data source is obtained, and the maximum number of fields is determined; The process of automatically allocating the width of each column of each data source according to the maximum number of fields and making the widths of each column the same includes: Get the number of fields of each data source, determine the maximum number of fields max, if max is a multiple of the number of fields of each data source, the maximum number of columns n is equal to max; otherwise, set the maximum number of columns n to a multiple of any integer greater than or equal to max, so that the width of each column is the same; Preprocess the data in each data source according to the structure of the data in each data source to obtain the meaning of each data source field; the structure of the data includes an attribute table and a list table; The attribute table has a header that occupies one row, and the values ​​corresponding to each column of the header that occupies one row; The table table has a header that occupies one line, and each line below the header contains the data of the list; Preprocessing the data in each data source according to the structure of the data in each data source to obtain the meaning of each data source field includes: If the attribute table is output, it is processed into a Map object format to obtain the meaning of each data source field; If the output is a list table, it is processed into an array of Map objects to obtain the meaning of each data source field; According to the meaning of each data source field, define the width of the header and each column of the table for the preprocessed data; make the width of each column of the table corresponding to the header the same as the width of each column in each row of the table content; Traverse the data in each data source and output the table header and table content in sequence through the report.

2. The method for outputting data from multiple data sources in a report according to claim 1, characterized in that: The process of processing into Map object format is: define four attributes of the header object array: key, display, value and length; the key is the column identifier; the display is the display content of the column; the value is the value corresponding to the field; the length is the multiple of the number of unit columns occupied by the column; The process of processing the array form of the Map object is: define three attributes of the header object array: key, display and length; where key is the column identifier; display is the display content of the column; and length is a multiple of the number of unit columns occupied by the column.

3. The method for outputting data from multiple data sources in a report according to claim 2, characterized in that: The process of defining the width of the header and each column of the table for the preprocessed data according to the meaning of each data source field is as follows: For the attribute table, merge two maps and set the width of each column; each Map object in the merged content contains the information of the table header and the columns in the table content; display is the report content under the table header, and value is the report content of the columns in the table; For a list table, first set the content and width of each column in the table header; then set the width and content for each row of table data; for each row of data, traverse the table header array to find the corresponding width.

4. The method for outputting data from multiple data sources in a report according to claim 3, characterized in that: The process of traversing the data in each data source and outputting the table header and table content in turn through the report is as follows: Traverse the array twice for the attribute table, and output the table header and two rows of table contents in turn; Traverse each data in the list table in turn, and output the table header and multiple rows of table content.

5. A system for outputting data from multiple data sources in a report, used to implement the method for outputting data from multiple data sources in a report as claimed in any one of claims 1 to 4, characterized in that: It includes acquisition module, preprocessing module, definition module and output module; The acquisition module is used to acquire the number of fields of each data source and determine the maximum number of fields; automatically allocate the width of each column of each data source according to the maximum number of fields, and make the width of each column the same; the maximum number of fields is a multiple of the number of fields of each data source; The preprocessing module is used to preprocess the data in each data source according to the structure of the data in each data source, and obtain the meaning of each data source field; The definition module is used to define the width of the header and each column of the table for the preprocessed data according to the meaning of each data source field; Make the width of the columns corresponding to the table header the same as the width of the columns in each row of the table content; The output module is used to traverse the data in each data source and output the table header and table content in sequence through reports.

6. A device for outputting data from multiple data sources in a report, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the method steps as claimed in any one of claims 1 to 4 when executing the computer program.

7. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps according to any one of claims 1 to 4 are implemented.