Office Star control is a document processing control (similar to Word control) launched by Shenzhen Zhidao Software Company based on mixed graphics and text. Office Star control completely encapsulates Office Star text, graphics, tables, charts, etc. function, providing hundreds of programming interfaces; in systems such as ERP, CRM, HR, OA, etc., output functions such as document processing, statistics, and reports that are very difficult to develop can be easily implemented by the Office Star control, and what you see is what you get. The effect is exactly the same as in reality. Office Star control is suitable for various development tools in the Windows environment (such as VB, VC, Delphi, C+Builder, PB, java, etc.), and has been extensively optimized for the Web development environment.
The following is a brief introduction to the specific methods of using the Office Star control in Delphi:
1. Registration control
If the user downloads and installs the Office Star control demo project, during the installation process, the installation program will automatically register the Office Star control into the operating system; if the user downloads the Office Star control separately, the user needs to register the control as follows:
Click "Start" → "Run"; enter the following command in the run dialog box:
regsvr32 <file name> registers an ActiveX control
regsvr32 /u<file name> Unregister an ActiveX control
2. Add components
If the Office Star control has been registered in the system, it can be added to the Delphi component panel. The specific steps are as follows:
(1) Select Delphi main menu Component->Import ActiveX Control, the system will open the Import ActiveX dialog box, in which all ActiveX controls that have been registered in the system are listed.
(2) Find the OStarOCX2 Active Control module (Version 1.0) item in the list column of the Import ActiveX dialog box, select it, and then click the Install button. The system will pop up the Install dialog box. In this dialog box, you can set the location of the component in the information storage package. It can be set to an existing default package, or a new package can be created to store the component information. If saved in the default package, the original component information contained in the default package will be replaced, and Delphi will uninstall the originally installed components, so here we create a new package file, as shown in the figure below.
(3) After clicking the OK button, the system will pop up the Pakage-OSTAR.dpk window, and a dialog box will pop up on it to confirm compilation and installation of the package, as shown in the figure below.
(4) Click the Yes button, the system will prompt that the component has been installed successfully, and the OStar component has been added to the ActiveX tab in the component bar. At this time, we can drag the component to the form for design.
Note: In Delphi6, when compiling a program containing the Office Star control for the first time, the following prompt message will appear:
[Warning] OSTAR.pas(766): Return value of function 'TOStarOCX2.OnOpenFile' might be undefined
The reason why these messages appear is because Delphi did not automatically write the function return value code when generating the code package related to the Office Star control. Therefore, if you encounter this situation, you need to manually add the return value code. The return value code is "Result:=", just add it in front of DefaultInterface, for example:
DefaultInterface.OnOpenFile(strFileName);
Change to
Result := DefaultInterface.OnOpenFile(strFileName);
3. Use controls
If the Office Star control has been successfully installed, you can use the Office Star control directly. If you need to use the Office Star control for report processing, you can use it as follows:
(1) Use the Office Star document designer to design the report style. The Office Star control demonstration project includes the Office Star document editor, and then set the report as required.
(2) Since the data filled into the report is filled based on the alias, it is necessary to set an alias for the data filled table element. Operation: Right-click the filled table element, select "Set Alias" in the pop-up menu, and then enter the alias in the pop-up dialog box. The light text shown in the above figure is the table element alias.
(3) After setting up the report, you can read the report file through the Office Star control, and the report function to open is OnOpenFile(const strFileName: WideString).
(4) If the Office Star control has opened a report, you can fill the report with data through the program. The filling data function is SetCellString(const strCellVar: WideString; const strText: WideString). The parameter strCellVar is an alias and strText is the filling data.
(5) The following is a screenshot of the example developed with Delphi. Users can also download the source code of the example from the Office Star control introduction page.