Crystal Reports for Eclipse Designer Guide Addendum
- 格式:pdf
- 大小:156.03 KB
- 文档页数:4
VB中水晶报表使用在VB中,水晶报表是非常常用的工具之一。
可以利用水晶报表来生成各种报表,如销售报表、库存报表等。
本篇文档将介绍VB中如何使用水晶报表。
水晶报表简介水晶报表(Crystal Reports)是由美国公司Crystal Decisions开发并推广的一款报表工具。
它能够通过与各种数据源连接,并结合VB等开发语言,使用丰富的报表设计工具,输出格式优秀、易于管理的报表。
水晶报表常被应用在财务、人力资源、生产管理等领域。
使用步骤步骤一:安装水晶报表在VB中使用水晶报表前,需要先安装相关组件。
水晶报表可以从Crystal Decisions官网下载,也可以通过在线安装程序直接安装。
步骤二:在VB中添加水晶报表安装完毕后,在VB工具箱中,通过右键单击“工具箱” -> “选择工具箱项目”,勾选“Crystal Report Viewer”和“Crystal Reports ActiveX Designer”,点击“确定”即可将水晶报表添加到工具箱中。
步骤三:设计报表在VB中建立一个报表项目,添加CrystalReport控件,然后我们就可以在报表设计器中进行样式、数据源、布局等相关设置。
设计完报表后即可在VB中引用并使用。
步骤四:运行报表在VB程序中,调用所设计的水晶报表,将数据源传入水晶报表中,再查看实际输出效果。
这一步需要注意传入的数据源要与报表设计器中设计的数据源一致,否则将无法正常输出报表。
注意事项1.数据源要与报表设计器中的数据源一致,否则报表将无法正常输出;2.在VB程序中使用水晶报表时,需要在程序头部声明相关引用;3.如果需要在VB项目中修改已经设计好的水晶报表,需要先关闭VB工程,再进行报表修改操作;4.水晶报表设计器中能够支持的数据源类型非常多,如Excel、XML、Access、Oracle等,使用中需要根据实际情况进行选择。
总结通过本文对VB中水晶报表的介绍,我们可以清楚的了解到水晶报表的作用及在VB中的使用方法,以更好地完成各种报表任务。
Crystal Reports ®For Visual Studio .NET®Designing and Viewing a Report in a Windows Application© 2001 Crystal Decisions, Inc. Crystal Decisions, Crystal Reports, and the Crystal Decisions logo are registered trademarks or trademarks of Crystal Decisions, Inc. Microsoft and Visual Studio are registered trademarks of Microsoft Corporation in the U.S. and/or other countries. All other trademarks are the property of their respective owners.Version 3.0Crystal Decisions, Inc.895 Emerson StreetPalo Alto, CA 94301Copyright © 2001 Crystal Decisions, Inc.Designing and Viewing a Report in a Windows ApplicationIntroductionCrystal Reports for Visual Studio .NET extends the powerful reporting capability of Crystal Reports on the Microsoft .NET platform. You can use the Crystal Report Designer in Visual Studio .NET to create a new report or modify an existing report. You can then keep the report on a local machine, or publish it as a Report Web Service on a Web server. Depending on whether you are developing a Windows or Web application, you can then host the report with either the Windows Forms Viewer or the Web Forms Viewer, respectively.This paper explains how to do the following in Visual Studio .NET:• create a new Crystal report in a project• add an existing Crystal report to a project• modify a Crystal report• host and view a Crystal report using the Windows Forms Viewer"Appendix A: Class Description for the Windows Forms Viewer Control" lists the set ofobjects, methods and properties for the Windows Forms Viewer. "Appendix B: ReportBinding Methods for the Windows Forms Viewer" lists the different methods of binding a local report to a Windows Forms Viewer.If you are interested in viewing Crystal reports using the Web Forms Viewer, please refer to the paper "Viewing a Report in a Web Application". For more information on Report Web Services, please refer to the paper "Exposing Reports as Web Services".For more information and updates, please visit our Web site at:/netSetting Up the Sample DatabaseWhen you install Visual Studio .NET, the sample database, xtreme.mdb, is automatically installed in C:\Program Files\Microsoft Visual Studio .NET\CrystalReports\Samples\Database\. The reports used in this walkthrough, OrderByCustomer.rpt and World Sales Report.rpt, assume xtreme.mdb is at this location.To change the location of xtreme.mdbIf you have installed xtreme.mdb at a location other than the default (i.e., C:\ProgramFiles\Microsoft Visual Studio .NET\Crystal Reports\Samples\Database\), you should do a Set Location for World Sales Report.rpt to point the report to the actual location of the database.1. In Visual Studio .NET, select File | Open | File. The Open File dialog box appears.2. In the Open File dialog box, browse to C:\Program Files\Microsoft Visual Studio.NET\Crystal Reports\Samples\Reports\General Business, and specify the file WorldSales Report.rpt. This opens World Sales Report.rpt in the Crystal Report Designer.Copyright © 2001 Crystal Decisions, Inc.3. In the Crystal Report Designer, right-click in a report area. Choose Database | SetLocation. The Set Location dialog box appears.4. In the Set Location dialog box, click the down-arrow under Current Data Source.Select the data source assumed by World Sales Report.rpt, "C:\Program Files\Microsoft Visual Studio .NET\Crystal Reports\Samples\Database\xtreme.mdb". You will point this assumed location to the actual location of the database.5. You may use any one of these database technologies to connect the report to the actualdata source: OLE DB (ADO), ODBC (RDO), Database Files (i.e., using native drivers), or (XML) (which is under More Data Sources). For the purpose of thiswalkthrough, under Replace with, double-click OLE DB (ADO). The OLE DB (ADO) dialog box appears.Note If you are already connected to xtreme.mdb, go to step 9. Or, if you areconnected to another database through OLE DB (ADO), select Make NewConnection.6. In the OLE DB (ADO) dialog box, highlight the OLD DB provider, Microsoft Jet 4.0OLEDB Provider. Then click the Next button.7. Provide the necessary information to access the actual data source: for DatabaseName, click the square button adjacent to the entry box. Select xtreme.mdb according to where you have installed it. Click Next.8. Update any advanced information for your data source, if necessary. Then click Finish.You will be returned to the Set Location dialog box.9. Redirect the report to look for the database in the actual location: in the Set Locationdialog box, under Replace with, highlight the actual location of the database. Click Replace. You will find this location updated under Current Data Source. Then click Close.10. If you have modified fields in xtreme.mdb, right-click in a report area, point toDatabase and select Verify Database. A message titled Verify Database appears.Click OK to fix up unmapped fields in the database.11. Choose File | Save World Sales Report.rpt to save the report with the updateddatabase location.Copyright © 2001 Crystal Decisions, Inc.Copyright © 2001 Crystal Decisions, Inc.Creating a Crystal ReportIn general, you can create a Crystal report as part of a Visual C#, Managed C++ or Visual Basic project in Visual Studio .NET. In this walkthrough, you will be creating reports in Visual C# projects.The following scenario illustrates how to create a Crystal report, OrderByCustomer.rpt, in a Visual C# project named Walkthrough. For simplicity, the report accesses a sample database via ActiveX Data Object (ADO), and displays orders grouped according to the customer.Creating a Crystal Report in a Visual C# Project1. In Visual Studio .NET, select File | New | Project . The New Project dialog boxappears. 2. In the New Project dialog box, select Visual C# Projects in the left pane. 3. Select Windows Application in the right pane.You may log on as a regular user and choose to create your project in any folder of yourchoice. For the purpose of this example, you will create the project in the default project folder for the user logged on as Administrator, C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects.4. Enter "Walkthrough" in the Name field. The default project location is displayed in theLocation field. Click OK . This creates the Visual C# Windows project, Walkthrough, inC:\Documents and Settings\Administrator\My Documents\Visual Studio Projects.5. In the Visual Studio Solution Explorer, right-click on the project Walkthrough. SelectAdd | Add New Item from the shortcut menu. The Add New Item – Walkthrough dialog box appears.6. In the Add New Item – Walkthrough dialog box, under Categories, with LocalProject Items highlighted in the left pane, select Crystal Report in the right pane.Enter "OrderByCustomer.rpt" in the Name field. Click the Open button. This invokes theCrystal Report Designer that will help you create and design OrderByCustomer.rpt.Copyright © 2001 Crystal Decisions, Inc.Copyright © 2001 Crystal Decisions, Inc.Designing a Crystal ReportThe Crystal Report Designer in Visual Studio .NET closely resembles the Designer of the Report Designer Component that runs on Visual Basic 6.0.When you create a report, the Crystal Report Designer opens with the Crystal Report Gallery that offers the following options: • use a Report Expert to guide you through the report creation process • open a blank report•create a new report from an existing reportFor the purpose of this example, you will use the Standard Report Expert to create a report titled OrderByCustomer. The OrderByCustomer.rpt file will access the xtreme sample database via ADO and display orders grouped according to each customer.1. In the Crystal Report Gallery , under Create a New Crystal Report Document ,select Using the Report Expert , if it is not already selected. 2. Under Choose an Expert , select Standard , if it is not already selected. Click OK . Thisinvokes the Standard Report Expert.Choose the Standard Report Expertto create a report.Copyright © 2001 Crystal Decisions, Inc.3. In the Data tab of the Standard Report Expert , double-click OLE DB (ADO). Thisinvokes the OLE DB (ADO) dialog box.4. In the OLE DB (ADO) dialog box, select Microsoft Jet 4.0 OLE DB Provider . ClickNext .5. Click the square button adjacent to the entry field for Database Name .6. In the Open dialog box, select the xtreme database under C:\Program Files\MicrosoftVisual Studio .NET\Crystal Reports\Samples\Database. Click Open .Select MS Jet as theOLE DB provider.Copyright © 2001 Crystal Decisions, Inc.7. In the OLE DB (ADO) dialog box, accept Access as the Database Type . Enter theappropriate User ID . Click Next . 8. Accept the default advanced information, and click Finish .9. The Standard Report Expert shows the new connection to C:\Program Files\MicrosoftVisual Studio .NET\Crystal Reports\Samples\Database\xtreme.mdb, with the tables and fields in the database. Expand Tables , select the Customer table and click Insert Table . Do the same to add the Orders table. Click Next .10. In the Links tab, click Next.Copyright © 2001 Crystal Decisions, Inc.11. In the Fields tab, add the Customer Name field from the Customer table and the OrderAmount field from the Orders table. Click Next .12. In the Group tab, under Available Fields , select the Customer Name field in theCustomer table. Click the Add button. Next, click the Finish button. You have just created a report that displays orders grouped according to each customer.13. To save OrderByCustomer.rpt with Walkthrough, right-click on the project Walkthroughin the Solution Explorer and select Save Walkthrough from the shortcut menu.14. Select File | Close Solution to close the solution.Later in the section "Modifying a Crystal Report", you will further modify the report with the Crystal Report Designer.Adding an Existing Crystal ReportIn general, you can add an existing Crystal report to a Visual C#, Managed C++ or Visual Basic project in Visual Studio .NET. In this walkthrough, you will be adding reports to Visual C# projects.The following scenario illustrates how to add an existing Crystal report, World SalesReport.rpt, to the Visual C# project Walkthrough that has been created in the previous section "Creating a Crystal Report".1. In Visual Studio .NET, select File | Open | Project to open Walkthrough.sln in the folderC:\Documents and Settings\Administrator\My Documents\Visual Studio Projects.2. In the Visual Studio Solution Explorer, right-click the Visual C# project Walkthrough.Select Add | Add Existing Item from the shortcut menu. This invokes the AddExisting Item – Walkthrough dialog box.3. In the Add Existing Item – Walkthrough dialog box, specify the location and name ofthe report you are adding. In this example, you are adding the sample report, WorldSales Report.rpt, from the folder C:\Program Files\Microsoft Visual Studio .NET\Crystal Reports\Samples\Reports\General Business (assuming C: is your installation drive forVisual Studio .NET).NOTE Select All Files (*.*) for Files of Type in order to display .rpt files in afolder.World Sales Report.rpt will appear as an item under the Walkthrough project in theSolution Explorer.Copyright © 2001 Crystal Decisions, Inc.To save World Sales Report.rpt with the project Walkthrough, right-click the projectWalkthrough in the Solution Explorer and select Save Walkthrough from theshortcut menu.Note World Sales Report.rpt assumes the database, xtreme.mdb, is at C:\ProgramFiles\Microsoft Visual Studio .NET\Crystal Reports\Samples\Database. If you have setit up previously at a different location on your machine, please refer to the previoussection "Setting Up the Sample Database" to have it set up properly.If you would like to modify the report, double-click the report in the Solution Explorer to launch the Crystal Report Designer. For further information on modifying a report with the Crystal Report Designer, please refer to the section "Modifying a Crystal Report” below. Modifying a Crystal ReportAfter opening a report in the Crystal Report Designer, you can further modify the report by manipulating its source of data, re-selecting and re-grouping data, and re-formatting its objects and layout. The Crystal Report Designer provides a user interface that closelyintegrates with the Visual Studio .NET IDE. It includes events that can be directlyprogrammed from within Visual Studio.The following three sections describe the layout of the Crystal Report Designer and list the basic report design functions.Copyright © 2001 Crystal Decisions, Inc.Copyright © 2001 Crystal Decisions, Inc.The Crystal Report DesignerThe graphic below shows the Crystal Report Designer displaying World Sales Report.rpt.A. Field ExplorerEnables you to add, modify or delete a field object. You can choose to display the Field Explorer by selecting from the Visual Studio menu bar View | Other Windows | Document Outline . B. Main Report windowDisplays the main report in a report window. For a report that contains subreports, there is a Main Report window and a separate report window for each subreport when you drill-down on the subreport (by double-clicking it). You can invoke the Report Shortcut Menu byA. Field Explorer: shows all the fields in the displayed report.B. Main report window: displays World Sales Report.rptCopyright © 2001 Crystal Decisions, Inc.right-clicking any blank space in a report window (i.e., right-clicking anywhere that is not occupied by an object or a section heading preceding each section in the report). C. Crystal Reports Main ToolbarIncludes icons for record selection, sorting, section and text object formatting. You may move or size this toolbar. You can also toggle the display of this toolbar by right-clicking on the Visual Studio .NET Standard Toolbar and checking / unchecking the item Crystal Reports – Main .D. Crystal Reports Insert ToolbarIncludes icons to insert summary fields, groups, subreports, charts, and pictures. You may move or size this toolbar. You can also toggle the display of this toolbar by right-clicking on the Visual Studio .NET Standard Toolbar and checking / unchecking the item Crystal Reports – Insert .Crystal Report Designer Functions Manipulating the Data SourceTo make changes to the data source of a report, select Database from the Report Shortcut Menu. You can then choose from a sub-menu of options to manipulate a data sourceincluding: re-linking tables, adding and removing a database, setting a database location, verifying a database, and converting to a different database driver.Formatting ObjectsUndo/Redo actions•You can undo (and redo) certain actions. To undo (or redo) an action, select Undo (or Redo ) from the Report Shortcut Menu. You can use Undo on more than one previous action; however, each Undo (or Redo) applies to one action at a time.•Alternatively, you can use the Undo and Redo buttons on the Visual Studio StandardToolbar, which apply to multiple actions.Inserting fields and objects• To insert a field or object (e.g., text, line, box, chart, and OLE object) into a report, select Insert from the Report Shortcut Menu.• Alternatively, you can insert a text, line or box object from the Crystal Reports tab of the Visual Studio Toolbox. You can insert each of these controls by dragging anddropping it, or copying and pasting it into the report. You can also select the desiredreport section and double-click the control for the desired object, which places the object in the top-left corner of the selected section.• You can add, modify or delete a field object through the Field Explorer.Modifying fields and objects• To format an object, right-click the object and choose Format from the shortcut menu.You can also edit, cut, copy, paste or delete the object from the same menu.• To format a chart object, use the Chart Expert by right-clicking the chart and selecting Chart Expert from the shortcut menu. You can also use advanced chart formattingfeatures by pointing to Format Chart from the same menu, and selecting theappropriate object.Formatting the Report Layout• To insert, delete or format a section in a report, select Format Section from the Report Shortcut Menu. Alternatively, you can select Insert | Section from the same menu. This invokes the Section Expert.• To modify the layout of a report, select Report | Style Expert.• To change page margins, select Designer | Page Setup from the Report Shortcut Menu. You can also turn on or off the ruler and grid in the report window. Changing the Report Design• Select Report from the Report Shortcut Menu. You can then select from a sub-menu of options to modify record selection, grouping, sorting, and miscellaneous local reportoptions. You can invoke the Report Expert to help you reformat a report. You can alsosave a report separately from the project.• To set miscellaneous global report options, select Designer | Default Settings from the Report Shortcut Menu.Setting Up a PrinterSelect Designer | Printer Setup from the Report Shortcut Menu. There, you can specify the printer, printer options, paper size, and orientation to be used when printing a report.Copyright © 2001 Crystal Decisions, Inc.Report Design Formatting ExampleOpen OrderByCustomer.rpt in the Crystal Report Designer if you have not done so, bydouble-clicking it in the Solution Explorer. In this example, you will formatOrderByCustomer.rpt by:• suppressing the Group Header section• suppressing the Details section• removing the Order Amount text object in the Page Header sectionTo do so:1. In the Crystal Report Designer, right-click in the Group Header (i.e., the gray area that islabeled "Group Header #1:Customer.Customer Name - A (Section 6)"). Select Suppress (No Drill-down) from the shortcut menu.2. Do the same for the Details section.3. Select the text object "Order Amount" in the Page Header section and press delete.4. Save OrderByCustomer.rpt by clicking the Save OrderByCustomer.rpt icon on theVisual Studio Standard Toolbar.What is the Windows Forms Viewer?Windows Forms in Visual Studio .NETA Windows Form in Visual Studio .NET is similar to a form in earlier versions of Visual Basic.In Visual Studio .NET, you can create a Windows application using any of the supported languages (i.e., Visual C# and Visual Basic). Upon creating a Windows application, Visual Studio .NET automatically opens a Windows Form for you in the project. You can then drag and drop controls from the Visual Studio Toolbox to the Design view of the Windows Form, and program in the Code view of the Windows Form.After you have designed a Windows Form, you can proceed to build it. If the project builds successfully, the Windows Form will be invoked automatically.Copyright © 2001 Crystal Decisions, Inc.Copyright © 2001 Crystal Decisions, Inc.The Windows Forms ViewerThe Windows Forms Viewer is a Windows Form control that allows you to host and view a Crystal report in a Visual Studio .NET Windows application. Similar to other Windows Form controls, adding a Windows Forms Viewer to a Windows Form requires the simple action of dragging a Windows Forms Viewer control from the Visual Studio Toolbox and dropping it in the Design View of the Windows Form. You can then specify the Crystal report to host in the Windows Forms Viewer.Similar to Visual Basic controls, Windows Form controls in the same Windows Form caninteract with each other. In particular, the Report Object Model supports interaction between a Windows Form control and a viewer control.Hosting and Viewing a Crystal Report Using the Windows Forms ViewerIn the walkthrough below, you will create a Visual C# Windows application to host a Crystal report with a Windows Forms Viewer. The Crystal report you will host isOrderByCustomer.rpt that has been created in the section "Creating a Crystal Report" and modified in "Modifying a Crystal Report”.Creating a Windows Form1. In Visual Studio .NET, select File | New | Project. This invokes the New Project dialogbox.2. In the New Project dialog box, select Visual C# Projects in the left pane.3. Select Windows Application in the right pane.You may choose to create your project in any folder of your choice. For this example, you will create the project, WindowsFormWalkthrough, in the same folder used above,C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects.4. Enter "WindowsFormWalkthrough" in the Name field. Accept the default location"C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects" in the Location field. Click OK. This creates a Visual C# Windows project namedWindowsFormWalkthrough in C:\Documents and Settings\Administrator\MyCopyright © 2001 Crystal Decisions, Inc.Upon clicking OK in the New Project dialog, Visual Studio creates a Windows Form (with the default name "Form1.cs") in the project, WindowsFormWalkthrough. Visual Studio opens the Windows Form in its Design View. The Visual Studio Toolbox also displays a set of controls for the Windows Form.Copyright © 2001 Crystal Decisions, Inc.Copyright © 2001 Crystal Decisions, Inc.Inserting the Windows Forms Viewer1. In Visual Studio .NET, when a Windows Form is opened, the Windows Forms tab of theToolbox displays a list of Windows Form controls, including the Windows Forms Viewer. The Windows Forms Viewer control is labeled as CrystalReportViewer in the Toolbox.TIP In Visual Studio .NET, you can anchor the Toolbox by clicking the "pin" icon at the top-right corner of the Toolbox.As well, items in a Toolbox tab can be displayed alphabetically by right-clicking on the tab, and selecting Sort Items Alphabetically from the shortcut menu.2. If you are not already in the Design View of Form1.cs, go to the Design View byhighlighting Form1.cs in the Solution Explorer, and clicking the View Designer icon on the Solution Explorer toolbar. 3. You can now add the Windows Forms Viewer to Form1.cs by draggingCrystalReportViewer from the Windows Forms tab of the Toolbox and dropping it in the Windows Form.Copyright © 2001 Crystal Decisions, Inc.After inserting the Windows Forms Viewer into Form1.cs, you can then move and resize it in the Design View of the Windows Form.The Windows Forms ViewerThe Windows Forms Viewer is currently available as a control with the following components: •Toolbar containing these buttons: • go to first page • page backward • page forward • go to last page • go to specified page• close current window (for group or subreport only) • print• refresh report • export• toggle group tree • magnify / reduce report • search• Group Tree•Main Report WindowSpecifying a Report to be hosted on the Windows Forms ViewerYou can specify a report to be hosted on the Windows Forms Viewer through theReportSource property of the CrystalReportViewer object. You can do so via the Properties Window in Visual Studio .NET (when the Design View of the Windows Form is active), or directly through code (in the Code View of the Windows Form).In the following example, you will host the report OrderByCustomer.rpt in the Windows Forms Viewer. OrderByCustomer.rpt is the same report created in the project Walkthrough in the section "Designing a Crystal Report" above.For a more detailed description of the different methods that you can use to bind a report toa Windows Forms Viewer, please refer to Appendix B.Specifying Report Through the Properties Window1. If you are not already in the Design View of Form1.cs, go to the Design View byhighlighting Form1.cs in the Solution Explorer, and clicking the View Designer icon on the Solution Explorer toolbar.2. Select the Windows Forms Viewer control.3. In the Visual Studio .NET Properties Window, scroll down to the ReportSource property.Click the down-arrow, browse and select the report with its full path name,"C:\Documents and Settings\Administrator\My Documents\Visual StudioProjects\Walkthrough\OrderByCustomer.rpt". (Both projects Walkthrough andWindowsFormWalkthrough have been created in the same location C:\Documents andSettings\Administrator\My Documents\Visual Studio Projects.)Copyright © 2001 Crystal Decisions, Inc.After you build and run the Windows application, the Windows Forms Viewer will display OrderByCustomer.rpt.Specifying Report Through the Code ViewAs an alternative to specifying the ReportSource property in the Properties Window, you can also specify the fill path name of the report directly in the Code View of Form1.cs, as highlighted in bold below:public Form1(){////Required for Windows Form Designer support//InitializeComponent();////TODO:Add any constructor code after InitializeComponent call//crystalReportViewer1.ReportSource="C:\\Documents and"+"Settings\\Administrator\\My Documents\\Visual Studio"+"Projects\\Walkthrough\\OrderByCustomer.rpt";}Building and Running the Windows ApplicationTo build the application, select Build from the Build menu. To run the application, select Start Without Debugging from the Debug menu.Copyright © 2001 Crystal Decisions, Inc.Appendix A: Class Description for the Windows Forms Viewer ControlNamespace CrystalDecisions.Windows.FormsClass name CrystalReportViewerMethods public virtual void CloseView(object viewURI)public override void Dispose()public void DrillDownOnGroup(TotallerNodeID groupInfo)public virtual void ExportReport()public virtual int GetCurrentPageNumber()public virtual void PrintReport()public virtual void RefreshReport()public virtual bool SearchForText(string text)public virtual void ShowFirstPage()public virtual void ShowGroupTree()public virtual void ShowLastPage()public virtual void ShowNextPage()public virtual void ShowNthPage([in]int PageNumber)public virtual void ShowPreviousPage()public virtual void Zoom(int ZoomLevel)Properties Int32ActiveViewIndexBoolean DisplayBackgroundEdgeBoolean DisplayGroupTreeBoolean DisplayToolbarBoolean EnableDrillDownTableLogOnInfos LogOnInfoParameterFields ParameterFieldInfoObject ReportObjectSourceObject ReportSourceRightToLeft RightToLeftString SelectionFormulaBoolean ShowCloseButtonBoolean ShowExportButtonBoolean ShowGotoPageButtonBoolean ShowGroupTreeButtonCopyright © 2001 Crystal Decisions, Inc.Boolean ShowPrintButtonBoolean ShowRefreshButtonBoolean ShowTextSearchButtonBoolean ShowZoomButtonInt32ViewCountStatusBar ViewerStatusBarToolBar ViewerToolBarEvents public event EventHandler Drill;public event EventHandler DrillDownSubreport;public event EventHandler HandleException;public event EventHandler Navigate;public event EventHandler Refresh;public event EventHandler Search;public event EventHandler ViewZoom;Copyright © 2001 Crystal Decisions, Inc.。
c#水晶报表入门教程:对比FineReport之报表填报水晶报表(crystal report)和FineReport都是很常用的报表工具,这里对比一下它们的报表填报功能。
表单表单的回填是水晶报表(Crystal Report)完全不能支持的功能。
FineReport 支持基于纯HTML的表单回填,支持各种主流的浏览器。
编辑风格表单提供普通文本编辑框、复选框、下拉列表框、下拉日历、文件上传等。
自动计算表单可支持类似EXCEL的自动计算功能,程序根据用户的设置在前端生成JavaScript表达式完成自动计算。
自动计算还可跨表,多sheet之间的相互运算。
数据的扩展允许报表单元格与数据库字段间任意对应,并有自动扩展的能力。
支持任意格式的表单回填数据。
直接回填到数据库用户填写的数据,都直接存储到数据库当中,无需中间环节。
多级汇总填报表单的报表同时还是个统计表,单元格数据可以有不同的来源和去向,这样可以先从下级机构汇总出数据再加以补充修改后填写到上级数据库中。
FineReport报表,其制表效率十倍于以国外产品为代表的传统报表工具。
对比点FineReport CrystalReport应用集成后台的环境支持纯JAVA,全支持个别产品只支持Windows前台的环境支持纯HTML,全支持一般仅支持IEJ2EE的应用服务器管理嵌入应用,可充分利用应用服务器各项能力独立服务器,应用服务器能力不可利用J2EE的WEB部署与应用统一部署单独安装部署,操作繁琐J2EE的应用接口丰富齐全,结合紧密通过网络协议,力度不足,统计图常采用古老的CGI方式Java Application集成支持非纯JAVA的不支持.NET的应用集成支持,独立服务支持页面的集成完全随意嵌入独立门户,很困难用户权限控制与应用程序一致独立机制很繁琐IDE集成能力有限支持不支持并发能力较强,4万单元格表在512M内存可并发50个以上基础程序对内存要求很高,并发数较少数据设计多数据源(集)直接间接支持完全分组(多层)支持支持,较繁琐完全交叉(多层)支持,无须专门处理支持,用专门的交叉模型不完全分组/固定行列支持编程准备数据上下分片支持,上下格式可不一致,固定变动混合格式一致的可编程准备数据,否则必须拼子表完成左右分片支持,固定变动混合,直接运算性能高固定列的可编程准备数据,采用DB叉乘性能很差跨行组运算支持,随意通用固定的简单跨行运算,跨组不支持独立格运算支持,随意通用固定几种运算,来自DB的要专门处理主从报表无须子表概念即可完成须用子表,数据无法沟通子表多层任意,格线可对一般两层,横向表不齐可缩放,横纵向均可自动摆位可自动摆位参数与宏均支持仅支持参数报表展现基本方案EXCEL网格式,方便快捷控件式,对齐繁琐导入EXCEL支持不支持套打绘制底图描绘精确度量报表输出格式标准HTML,PDF,word完全不失真的EXCEL,带格式文本PDF,特殊HTML,丧失格式的EXCEL,无格式文本统计图输出格式GIF,JPG,PNG GIF,JPG打印分页分栏横纵向均可,强制分页仅支持纵向,且不可分栏其它打印控制一纸多页,补空行,缩放缩放表单编辑风格文字编辑、下拉选择等不支持自动计算支持合法性检查支持数据库对应随意自动,行/列/交叉均可多级汇总填报支持部署和应用集成WEB部署FineReport报表工具的服务程序以JAR包形式出现,可与应用程序统一打成包一起部署在应用服务器上,安装非常轻松。
JA V A水晶报表使用过程及注意事项一、第一阶段1.软件安装:Crystal Reports XI + Eclipse2.首先打开Eclipse,新建报表模板:new→other→ Crystal Reports web Project,姑且命名为Pen 注:此时可能会显示错误,不要紧,请不要理会。
3.在Java Resources:src下面的默认包中创建欲使用的JavaBean,如:Pen.java注意:一定要保存4.右键点击JavaBean下面的,选择Crystal Report→ add to a new Crystal Report,并自行创建名称注:名称的创建是有用处的,这便是生成模板的过程5.这时选择左下角的Layout,即可看见可视化编辑窗口,在右侧的Field Explorer中可选择所创建的虚拟字段(所创建的JavaBean中的属性)放入窗口中。
二、第二阶段6.打开MyEclipse,创建web project,命名为PenDemo。
7.复制Pen(Crystal Reports web Project中)项目src文件夹下的com文件夹、CRConfig.xml和log4j.properties文件到PenDemo(MyEclipse中的正常web project)中相应的目录下。
注:这时你会看见有错误,下一步解决8.复制Pen(Crystal Reports web Project中)项目WEB-INF下的全部内容到PenDemo(MyEclipse 中的正常web project)到相应的目录下。
注:请刷新PenDemo项目你会发现错误消失9.请将PenDemo(MyEclipse中的正常web project)src下面包中的生成的report模板cut至webroot 下。
10.copy资料包中的除了web-inf以外的所有文件(夹)至项目工程PenDemo相应的目录下注:刷新又出现错误了,不要紧,这是因为我们本末倒置的缘故,具体原因自己思考11.为了节省时间,我们可以copy资料包中的相关对数据操作的业务类来直接用,首先copy资料包中的DataSource.java至PenDemo项目中,存放的包及路径自己定。
Crystal Reports for Eclipse Designer Guide Addendum
©2007Business Objects.All rights reserved.Business Objects owns the following U.S.patents,which may cover products that are offered and licensed by Business Copyright
Objects:5,555,403;6,247,008;6,289,352;6,490,593;6,578,027;6,768,986;6,772,409;6,831,668;6,882,998and 7,139,766.Business Objects and the Business Objects logo,BusinessObjects,Crystal Reports,Crystal Xcelsius,Crystal Decisions,Intelligent Question,Desktop Intelligence,Crystal Enterprise,Crystal Analysis,Web Intelligence,RapidMarts,and BusinessQuery are trademarks or registered trademarks of Business Objects in the United States and/or other countries.All other names mentioned herein may be trademarks of their respective owners.Business Objects products in this release may contain redistributions of software licensed from third-party contributors.Some of these individual components may
Third-party
Contributors also be available under alternative licenses.A partial listing of third-party
contributors that have requested or permitted acknowledgments,as well as required
notices,can be found at:/thirdparty
Crystal Reports for Eclipse Designer Guide Addendum
Data source connections
Data source connections
Eclipse3.3replaces the Database Explorer view with the Data Source
Explorer view,which provides a new way to create connections.
This topic explains how to connect to a Derby database in Eclipse3.3.It also
describes how to connect to the Xtreme sample database.
You will need to install the Derby Embedded Database before you can
connect to it.For information on how to install the database,please go to
the Apache website:
/derby/
To find the Xtreme.jar file
1.On the Window menu,click Preferences.
2.Expand the Crystal Reports node,and click Engine.
3.Write down the path for the Xtreme.jar file.
To connect to a Derby data source
1.In the Data Source Explorer,right-click Databases and select New.
2.Select the Derby Embedded Database and click Next.
3.Type a name for your connection and click Next.
The Derby Embedded Database dialog box appears.
4.In the Select a driver from the drop-down section,click the browse[...]
button.
The Driver Definitions dialog box appears.
5.Search for the version of Derby that you have installed and click Add.
The New Driver Definition dialog box appears.
6.Select the Derby Embedded JDBC Driver and click OK.
The Edit Driver Definition dialog box appears.
7.Remove the default derby.jar file.
8.Click the Add Jar/Zip button.
Crystal Reports for Eclipse Designer Guide Addendum3
Crystal Reports for Eclipse Designer Guide Addendum
Data source connections
9.Browse to the\lib\folder where you installed the Derby files and select
the derby.jar file.
10.In the Properties,modify the following properties:
•Connection URL=
jdbc:derby:jar:(<path to Xtreme.jar>)Xtreme
<path to Xtreme.jar>is the full path to the Xtreme.jar file.
•Database Name=Xtreme
•Password=test
A Password is not required for the connection but in order to add it to
the report,it must be supplied.
•User ID=test
11.Click OK.
12.In the Driver Definitions dialog box,select the Derby Embedded JDBC
Driver and click OK.
13.In the Derby Embedded Database dialog box,ensure the database
location looks like the following value:
jar:(<full path to Xtreme.jar file>)Xtreme
14.Click test connection to verify the connection.
15.Click Finish.
16.In the Databases list,right-click the connection that you created and
select Connect.
The connection will expand and show you the database.If you continue
to expand,you will see the list of tables.
17.To add the tables to the report,you can right-click the table or
drag-and-drop onto a report.
4Crystal Reports for Eclipse Designer Guide Addendum。