Application of Huabiao cell module _it Industry

Source: Internet
Author: User
Tags function definition
Nanjing Tian Phase Software Co., Ltd. Zhu Xiaobing

My unit in 2002 to purchase a cell component, the use of cell components to develop a number of projects, is the use of some of their own feelings and experience to organize a written, and look forward to getting everyone's advice.
Installation article
The cell component is a control that follows the ActiveX standard and is easy to install into your own development environment.
1, the installation of Huabiao Company's cell components.
2, Open Delphi, choose Componentimport ActiveX Control ... Menu.
3. In the Import ActiveX form, select the Cell5.2 ActiveX control module option and click the "Install ..." button below.
4, in the Package form, click on the "Compile", "Install" button, exit when you choose not to save.
5. A cell icon appears in the ActiveX page of the control area, indicating that the installation was successful.
6, directly drag the cell icon to the form can be used.
7, the cell component provides several development environment in the demo, can directly comply with the use, that basically is a ready-made product.
Primary articles
Initial use of cell components for two development, mainly used in the form of play, table calculation, table control and other functions.
1, Form sets dozen
Many administrative departments in the issuance of certificates or format file management process, the requirements for the performance of the set is relatively high. Nanjing Construction Engineering System issued the completion of the building project record certificate is used in Word layout template, but the actual content and template reservation space does not match, or more knock on the line, the entire format of chaos, the staff will be again typesetting, repeated printing, debugging, it is a waste of time, waste paper, waste of energy. We used the cell component to make a template, combined with business System automatic Extraction Project Overview, now users click on the project name, immediately on the screen to see the full contents of the certificate, the text in each cell can be adjusted size, automatic line-wrapping and other methods to control the display, and only the original to manually fill in the content, Greatly improve the efficiency and accuracy. This point in Jinshan WPs and Microsoft Word, Excel are not implemented.

Screen registration interface set to play preview effect
Technical tips: To the set of hit to control whether the contents of a cell are printed, there are two ways: first, the end user enters the cell property directly set. Second, developers use the Setcellprinthide command to control whether the printer prints.

2. Table Calculation
This is similar to the computing function of Excel, it is not much to say.
3, the control of the table
Recently wrote a business order operation and process management corresponding to the software project, requirements in a complete business order, a registration of the first half of the content, can not see the following records and approval content, B can only view a part of the content, and not allowed to modify a registration of any content, but for their own content can be entered, Such a layer of control, the last F can see the entire content, but still do not allow modification. After a variety of experimental comparisons, the final selection of cell components to complete the project's main frame part. The entire program uses more than 80 lines of statements to achieve control over 50 kinds of tables, and the structure is clear, maintainable, enough to cope with the future increase in the number of business items table functions.

A registration (b Test record is not visible)

b Test (a Content section prohibited, all prohibited)
Technical tip: We first close the direct operation of cell properties, and then combined with the operation of various process points and cell components of the command to control the form of presentation. The following commands are used: Setcellshowhide controls which cell contents are displayed or hidden on the screen, Setrowunhidden/setrowhidden controls which rows need to be displayed or hidden, and setcellinput controls which cells are input or read-only.
Improve the article
Cell components as a control, it seems that only passively fill the data, to achieve the table itself, such as the calculation of the play, a long time we are so used. With the application in depth, we feel that the cell table as a host program, based on the user input in the table to our development environment request is necessary, and control more flexible. After the introduction of the Huabiao Company, the original mystery in the cell component provided by the custom function, we can implement some forms in the custom function, including interface control and background database processing, so that the cell components fully integrated with our development environment, Maximize the functionality of the cell component and the convenience of tables.
Define the function interface in the from create event.
Procedure Tform1.formcreate (Sender:tobject);
Var
strfun:widestring;
Begin
Strfun: = ' "Day function" String txinterface (double n) ';
Cell1.definefunctions (Strfun); Add a custom function to the cell
Strfun: = ' "" "Day Function" double Txgetdb (double n) ';
Cell1.definefunctions (Strfun);
End;
Defines the function implementation in the cell's Custom function event Calcfunc. The Calcfunc event interacts with the development environment based on the mechanism that is immediately triggered by the validation of the input in the table. The cell built-in function is not valid for the Calcfunc event, and the Huabiao company designed it very reasonably.
Procedure Tform1.cell1calcfunc (sender:tobject; const name:widestring;
RetType, Paranum:integer);
Begin
If Name= ' txinterface ' then//perform interface operation Custom function
Begin
Application.createform (TForm2, Form2);
Form2.showmodal;
Form2.free;
Cell1.setfuncresult (1, ' Call form success! ", 1);
Because the function definition return type is string, the actual return ' Call form success! '
End
If Name= ' txgetdb ' then//Custom function to perform database operations
With Datamodal do
Begin
If Sptmp.active then sptmp.close;
Sptmp is an example of Adostoredproc. Returns data obtained from a stored procedure
sptmp.procedurename:= ' pjc_set_trpt ';
SpTmp.Parameters.Refresh;
sptmp.parameters.paramvalues[' @XBH ']:= ' ' 1010 ';
SpTmp.Parameters.ParamByName (' @RBH '). Direction:= Pdoutput;
Sptmp.execproc;
Cell1.setfuncresult (sptmp.parameters.paramvalues[' @RBH '], "", 0);
Sptmp.close;
End
End

Here is the actual usage.

Enter the "=" number in the cell table, pop the formula box, and pass "? button to select the Txinterface function or directly enter the Txinterface function, and finally select the "√" button, will immediately trigger the Calcfunc event in the Txinterface function body, pop-up Form2 form, You can do your own thing in the Form2 form.
Another benefit of using custom functions is that people can't copy your form, because it doesn't work without your program.
In conclusion, we have solved many practical problems with the powerful capabilities of the cell component.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.