Introduction to Design reports this article introduces the implementation ideas and solutions of a WEB report design tool. this tool can be connected to a database, allowing users to design their own reports and obtain report data from the database, the modified data can be stored back to the data design.
This article introduces the implementation ideas and solutions of a WEB report design tool, which can be connected to a database, allowing users to design their own reports and obtain report data from the database, the modified data can be stored in the database. This tool can be used to design reports in any form (regular and irregular). It can be used not only as a final product, but also as a developer, you can also develop your own products as a design tool for reports and databases. One goal is to prevent developers (at least themselves) from "report hard work ".
Preface and question proposal
I encountered a lot of design reports during the software development process of C/S structure and B/S structure. Users have a large variety of reports to implement, and some reports need to be implemented after system acceptance. When developing a C/S Structure Report, you can use tools such as PB, EXCEL, and formula one to prepare tables and use ASP to develop reports of B/S organizations, XML, XSL, and so on can generate tables in one cell. the style design of the report has been completed for a long time, so that you can take a rest, but not yet. You still need to design a database, design the method and function for generating reports, and design the interface for modifying reports and the function for saving data. each report must be manually submitted by developers. the user can easily submit the report for testing: the format of a table is incorrect, the formula of a table is incorrect, the size of a table is incorrect, and several new tables are added ...... This makes people feel dizzy, just a little sense of accomplishment, a little relaxed and sighed, alas rushed to run ...... It would be nice to let users do these dirty work on their own!
Just after receiving a WEB office system project of the financial system, there is a thick stack of reports to be implemented. this is only a preliminary requirement. Simply put, we will design a "report Design Tool ", we hope to release the report work in the future. of course, it is implemented on the WEB.
As a report design tool, I used to design a C/S structure system and implemented it (with PB6). the user used it quite well. But there are disadvantages: first, it is not easy to transplant and use on the WEB. Second, it is only possible to display reports, not to modify data in reports, but not to add data. How can we implement it on the WEB?
Implementation method
To use a WEB report design tool, you must first know what the report is? How is it produced and implemented? Let's take a look.
What is a report? In this case, some data is stored in tables in a fixed position in a fixed format. Since it is a table, there is a "table" with a "grid ", first, we need to create a "grid", a "grid", and a "row" or a "column", and then a "row (column)" and a "row (column) to create a table.
Although it is also "spelled out" by the grid, some tables are easy to draw and some are difficult to draw, as shown in 1 and:
Obviously, the report shown is better than the report shown. we call a type Table "Regular Report" and a Type report "irregular report ".
After talking about the nonsense for a long time, how is the report generated and implemented? I think there are two methods: "painting" and "filling ".
"Drawing a table" is to generate a grid and put the data in a grid by format, that is, the format data is generated at the same time. as a result, the entire table is finished and the data in the table is also available, the report is generated. This method is suitable for generating regular reports so that you can draw a report row by row or column by column. This method has the advantages of fast Report Generation (batch data processing) and simple processing procedures (one loop statement is enough ).
"Filling in a table" is completely different from "drawing a Table". you must first have a table format and then enter the specified data in the specified table location. This method is applicable to both generating irregular reports and generating regular reports. The advantage of this method is that it has a wide range of applicability, but the disadvantage is that it is slow because it needs to obtain the table sample first and then retrieve the data one by one, fill in the cells one by one.
Which implementation method should be adopted? There are two solutions:
1. separate processing: When designing a report, let the user determine whether the report is regular (this is very simple). if it is regular, the report will be generated by "drawing a Table, otherwise, it is generated by filling in the table.
2. unified processing: All data is generated by filling in the table.
I think the computer speed is still improving rapidly. the hardware speed can reduce the software speed, but it is mainly to simplify the software design and processing, the second method is used: Fill in the table.
I decided on the implementation method and began to consider some details and technical matters: What issues should I consider to implement this WEB report design tool and what problems should I solve?
Problems to be solved
Now we need to consider how to implement it. At the beginning, I thought for a moment, wouldn't I solve these problems:
1. how to create a table by drawing a table? Must be implemented in the browser!
-- Simple: use DHTML and XML/XSL.
2. how to save the table sample?
-- Simple: both exist in the TEXT field of the database.
3. how to connect to the database?
-- Simple: A special attribute is defined for representation.
4. how to display data?
-- Simple: DHTML technology and XML/XSL can be used.
5. how to modify data?
-- Simple: Can I detect events!
6. how to save data?
-- Simple: Write it in the database.
After careful consideration, we can find that there are many problems:
7. how to draw a table? What painting is used? In particular, it must be implemented in a browser.
8. how to design a table style? Such as bold, underline, italic, decimal words, merged tables, and deleted tables.
9. how to save the table sample? In what format? Where does it exist?
10. how is the data display position defined? How to define it? How to save the defined results? Where does it exist? How to fill in data?
11. how is the display format of a single data defined? How to define it? How to save the defined results? Where does it exist?
12. how to connect a report to a database? How to obtain report data? How do I define conditions for getting data? How to define it? How to save the defined results? Where does it exist?
13. if you want to add a new report without a ready-made database table, how can you design a database? How should we design a database?
14. how do users know the meaning of database definitions? How do I know which field and record in the database table should be taken for a grid?
15. how do I know that the report data has been modified (added) by the user? How does the data correspond to fields in the database table? How can we know which cells of data are combined as a complete record in the database table? How can we know that the user input data is sufficient to form a complete record? How can we save the modified (added) data?
16. how do I save data that does not need to be created separately in a database table?
17. design of the data balancing relationship of reports? How to define it? How to save the defined results? Where does it exist?
18. how to implement the automatic calculation formula? How to define it? How to save the defined results? Where does it exist?
19. how to extract data from other reports to generate a new report? How to define it? How to save the defined results? Where does it exist?
20. how to define a summary of reports (data from branches generates data from the General Organization )? How to save the defined results? Where does it exist?
21. how to implement data reporting-that is, data format conversion? How is the conversion program designed? How to save it? Where does it exist?
......
The more you think about the problem, the more troublesome you will feel. simply give up and forget it. for example, if you are a slow person like yourself, you may have finished designing this tool, A large number of reports have long been completed.
Looking back at the notes and collected data written for the design of this report tool, I am unwilling to do it; then I will renew the report size, which is too heavy and too much-is it hard to work? No! It's worth a bit of trouble for your future! But how should we start with so many problems that need to be solved? What are the key issues?
Key issues
Look at the scenery outside the window, wait for a moment to calm down, and then look at the listed problems. One problem and one problem are measured and compared one by one, the first problem to be solved is how to implement the "table sample design tool. Because all the operations such as report design, display, modification, and storage are implemented in the tool environment, database Connection, table sample storage, and so on have to be implemented and adjusted around the expression and interface form of the tool.
Now that you have the idea of a job, start designing it! Don't be busy. the design of the "tool" is not fixed yet!
Comparison of several solutions
There are many ways to design a table sample on the WEB:
1. use XML/XSL/DHTML/HTML technology to implement
2. use the WebBrowser ActiveX control of IE to implement
3. write ActiveX controls by yourself
4. write your own Java Applet for implementation
5. use third-party controls
Which solution is better for me?
First, let's take a look at the features of each solution. The results are listed as follows:
If you can obtain free third-party software, it is undoubtedly the best solution of 5th. Check whether there is. The SheetSpace control in Microsoft Office Web Components is found. although it is not free (MS Office2000 + must be supported), all users use MS Office, which not only reduces development costs, the user is also used to the operation, and selects the sheet space control in Microsoft Office Web Components.
Solution
Now that the key issues have been solved, all the other issues can be solved. The following describes the solutions to the problems:
1. how to create a table by drawing a table? Must be implemented in the browser!
-- Design a table sample in the SheetSpace control of Microsoft Office Web Components, or design a table sample in ms excel, and then import it to the SheetSpace control of Microsoft Office Web Components; design a program for importing ms excel. The data display format, paging, fixed header, font size, color, and so on are all designed in the table sample.
2. how to save the table sample? In what format? Where does it exist?
-- Save the result of the sheet space control in Microsoft Office Web Components to the TEXT field of the database. The format of the sample is the HTML format of ms excel, which can be directly obtained by the sheet space control in Microsoft Office Web Components.
3. how to connect to the database?
-- Define a field attribute to indicate the database table corresponding to the report)
4. how to display data?
-- Extract report data from the database and save it to the client in XML format. The data is displayed in the SheetSpace control of Microsoft Office Web Components and the obtained report data is filled in the specified cell.
5. how do I know that the report data has been modified (added) by the user? How does the data correspond to fields in the database table? How can we know which cells of data are combined as a complete record in the database table? How can we know that the user input data is sufficient to form a complete record?
-- Check the change event of the SheetSpace control in Microsoft Office Web Components. compare the current cell value with the original data. if the value is different, modify the original data and set the modification flag. The correspondence between the data and the database field is obtained according to the formula. In this way, we can know which cells of data are combined as a complete record in the database table. For the added data, a dedicated input tool is designed to indicate which data you need to enter is complete.
6. how to save data?
-- Submit data with the modify (add) flag in XML to the server. the server processes the data and then modifies the corresponding data in the database.
7. how to design a table style? Such as bold, underline, italic, decimal words, merged tables, and deleted tables. How is the display format of a single data defined? How to define it? How to save the defined results? Where does it exist?
-- The SheetSpace control in Microsoft Office Web Components provides these operation functions. these functions are displayed on the page in the form of menus and provide user operations. The results of user operations are saved in the table sample, and stored in the database together when the table sample is saved.
8. how is the data display position defined? How to define it? How to save the defined results? Where does it exist? How to fill in data?
-- Design a formula design and interpreter. the data to be displayed is saved in the table sample in the form of a formula. the location where the formula is located is the location where the data is to be displayed, the format of the cell where the formula is located is the data display format (such as font and color ). The formula is stored together with the table sample. When displaying data, obtain the data according to the formula and fill it in the cell.
9. how to obtain report data? How do I define conditions for getting data? How to define it? How to save the defined results? Where does it exist?
-- Each report defines the "query condition" attribute to obtain a complete report data. This query condition directly corresponds to the database field. This attribute is stored in the database together with the report table sample.
10. if you want to add a new report without a ready-made database table, how can you design a database? How should we design a database?
-- Design a database design tool on the web page so that users can design the database structure according to their actual needs.
11. how do users know the meaning of database definitions? How do I know which field and record in the database table should be taken for a grid?
-- Because a database design tool is provided, the database structure designed with this tool requires that the title of this field be entered, that is, the description of the field; when you define a formula, it is not a boring English field name, but the field title, which is easy to understand.
12. how do I save data that does not need to be created separately in a database table?
-- Separate the reports that do not require separate database creation. all the reports are stored in a common table) the data in includes both the report style and report data.
13. how to design the data balance relationship of reports? How to define it? How to save the defined results? Where does it exist?
-- The data balance between reports is fully achieved using the EXCEL formula. The formula is stored together with the table sample. The sheet space control in Microsoft Office Web Components supports most ms excel formulas. The formula usage and syntax are exactly the same as those in ms excel.
14. how to implement the automatic calculation formula? How to define it? How to save the defined results? Where does it exist?
-- The formula of ms excel is used for implementation, such as sum and avg. the formula is stored together with the table sample.
15. how to extract data from other reports to generate a new report? How to define it? How to save the defined results? Where does it exist?
-- A report has a property called the "fetch program", which is used to extract data from other database tables and insert it into the database table corresponding to this table.
16. how to define a summary of reports (data from branches generates data from the General Organization )? How to save the defined results? Where does it exist?
-- A report has a property called "summary Program", which is used to collect data from reports of lower-level organizations to generate report data of the organization.
17. how to implement data reporting-that is, data format conversion? How is the conversion program designed? How to save it? Where does it exist?
-- Reporting data is actually a conversion of data formats. it can be easily designed using XSL. The XSL conversion program is saved as a text file in a specified directory. the file name corresponds to the report one by one. To generate report data, convert the report data into a text file, and save it to the user's specified location on the client machine.
The full definition of a report is stored in the data. The structure of the database table is as follows:
Table 2: Report definition structure
For ease of operation, the batch processing function is added, allowing users to extract and summarize data in batches, simplifying user operations.
The entire report processing process is as follows:
1. design database definitions
2. design the report style
3. Insert the fetch formula
4. set query conditions
5. design the summary program
6. design the data fetch program
7. query reports
8. Summary Report
9. batch summary reports
10. extract report data
11. batch extract report data
12. Generate the report file
Design results
Now, the coding work has been completed for more than a month. the database design interface 3 is shown, and the report design interface 4 is shown.
: Database design interface
: Report design page
Try it out for users. The results are good, and dozens of various reports can be easily solved. Huang Tian is not "bitter. In this way, I used another week to design a chart design tool, and the user responded very well. The chart design page is shown in figure 4.
: Chart design page
Summary
This article discusses how to implement an effective WEB report design tool. Users who need to design a large number of reports, especially those who frequently change the report format and quantity, can use the reports conveniently. Developers can also save a lot of work.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.