After using finereport for a while, the company switched to table cell, which is cheap. When I first switched to cell, it was very painful. I used to use it. It was a bit difficult to find myself in the sea, the cell Web plug-in can only be used in IE (the table cell Web plug-in cannot be displayed in IE8), which is inferior to finereport. However, the customers are basically Internet Explorer, and there is no incompatibility problem. That is, when developing reports, the efficiency is greatly reduced, but it is also a hundred times better than pure handwriting.
When I study, I always have the habit of taking some notes. This article is actually an example of my learning about table store, a simple summary table.
Final Effect
A list of products with only four records, and the total price of each product, and the total quantity and unit price of all products (it seems meaningless to calculate these two items, just to practice ).
Create a Report Template
Designing a table sample in advance can reduce the amount of code. because the number of data entries in this example is fixed, the summary formula is also included in the report template.
Create a report with the designer "Super report" (the name is dazzling), save as "product-list.cll", and design the table as follows:
- Set the format of cells C2 to C6 to numeric without retaining decimals.
- Set the cell formats D2 to d6 and E2 to E6 to numeric type, retain two decimal places
- Set the en formula to Cn * DN (2 ≤ n ≤ 5)
- Set the formula of C6 to sum (C2: C5)
- Set the D6 formula to sum (D2: D5)
- Set the formula of E6 to sum (E2: E5)
- Delete unnecessary rows and columns
Embed reports in webpages
To use the cell template on the webpage, make sure that the table cell plug-in has been correctly installed.
Create an HTML page product-list.html with the following content:
<HTML>
<Head>
<Title> product list </title>
<SCRIPT type = "text/JavaScript">
Window. onload = function (){
// Use a Report Template
Cell. openfile ('product-list. cll ','');
// Add data
Cell. s (1, 2, 0, 'a1001 ');
Cell. S (2, 2, 0, 'product 1 ');
Cell. D (3, 2, 0, '123 ');
Cell. D (4, 2, 0, '98 ');
Cell. s (1, 3, 0, 'a1002 ');
Cell. S (2, 3, 0, 'product 2 ');
Cell. D (3, 3, 0, '123 ');
Cell. D (4, 3, 0, '123 ');
Cell. s (1, 4, 0, 'a1003 ');
Cell. S (2, 4, 0, 'product 3 ');
Cell. D (3, 4, 0, '42 ');
Cell. D (4, 4, 0, '123 ');
Cell. s (1, 5, 0, 'a1004 ');
Cell. S (2, 5, 0, 'product 4 ');
Cell. D (3, 5, 0, '35 ');
Cell. D (4, 5, 0, '123 ');
// Recalculate all formulas
Cell. calculateall ();
// Display gridlines
Cell. showgridline (1, 0 );
// Hide the horizontal and vertical scroll bars
Cell. showhscroll (0, 0 );
Cell. showvscroll (0, 0 );
// Hide the table Tab
Cell. showsheetlabel (0, 0 );
// Hide row and column labels
Cell. showtoplabel (0, 0 );
Cell. showsidelabel (0, 0 );
// Cell A1 obtains the focus
Cell. movetocell (1, 1 );
// Prohibit data modification
Cell. protectsheet (0 ,'');
}
</SCRIPT>
</Head>
<Body>
<Object ID = "cell" classid = CLSID: 3f166327-8030-4881-8bd2-ea25350e574a
Style = "height: 111px; width: 418px"> </Object>
</Body>
</Html>
Note:
- If the data in a cell is numeric and involved in calculation, you must add the data to the numeric type. Otherwise, the calculation results will be affected.
- After adding the data, you must execute the calculateall () method to ensure that all formulas are recalculated to obtain the correct sum value.
- To prohibit users from directly editing data, you must execute the protectsheet () method to lock the report.
Attachment:
Table Cell Application-productlist