Add Calculated Fields to the Crystal Reports Report
Thông tin tài liệu:
Nội dung trích xuất từ tài liệu:
Add Calculated Fields to the Crystal Reports Report 10.3 Add Calculated Fields to the Crystal Reports ReportAlthough creating reports based on given fields in tables is fine, it just does not give theflexibility I need. To have that, I need to know how to add calculated fields to my reports.TechniqueIn Crystal Reports, calculated fields are known as formulas. To create and edit formulas,you will use the Formula Editor (see Figure 10.16).Figure 10.16. You can display this Formula Editor from either the Report Expert or the Report design.When youre in the Report Expert, you can add a new formula by clicking on the Formulabutton, located on the Fields tab.In Report design, you can add a field by opening the Field Explorer, located to the left ofthe IDE with the toolbox, and expanding the Formula Fields tree. You can also right-clickon the Formula Fields base node and choose New to add a new formula.Formulas are similar to T-SQL expressions in that you can combine fields or values withoperators to create a Formula field. For example, a formula called @TotalPricePerUnit isbeing created for this How-To. You saw it displayed in Figure 10.16. The expressionused is this:{Invoices.UnitPrice}*{Invoices.Quantity}You can use Formula fields in summary sections and grand totals. The best way to verifya formula is to create it when you use the Report Expert to create a report.StepsOpen the Visual Basic .NET-Chapter 10 solution. In the Solution Explorer, you will seethe report rptHowTo10_3.rpt. Scroll over to the left so that the last column is visible. Thisis the Formula field. 1. Right-click on your project in the Solution Explorer and choose Add New Item from the Add menu item. Type the name of the report in the Name field and click Open. The Crystal Report Gallery dialog box opens. 2. Leaving the defaults as they are, which is to use the Report Export and create a Standard report, click the OK button. You are taken to the Report Expert, with the Data tab displayed. 3. Double-click on the OLE DB (ADO) node in the Available Data Sources tree. If you havent chosen a data source before, the OLE DB (ADO) dialog box opens asking you to choose an OLE DB provider. Choose Microsoft OLE DB Data Provider for SQL Server and click Next. You are requested to enter connection information. For this page, type (local) for the server, check Integrated Security, and type Northwind for the database. Click Finish. Your Available Data Sources will now indicate (Local) under the OLE DB (ADO) node and Northwind under the local connection. 4. Expand the tree under Northwind to get to the first DBO, and then expand Views. You will see the views listed, including the Invoices view. Highlight the Invoices view and click Insert Table. The view is displayed in the Tables in Report list (see Figure 10.17). Click Next. Figure 10.17. The Report Expert considers both tables and views as tables. 5. From the Fields tab, add the following fields: Invoices.CustomerName, Invoices.OrderID, Invoices.UnitPrice, and Invoices.Quantity. 6. Click on the Formula button. Type TotalPricePerUnit. Crystal Reports puts the @ before the formula name from now on. You are then brought into the Formula Editor, shown back on Figure 10.16. 7. Type the formula {Invoices.UnitPrice}*{Invoices.Quantity}; then press Ctrl+S to save and close the dialog box. An alternative is to double-click on the fields you want to include. 8. Now select the formula you just created, and add it to the fields to include. 9. You can now go on to select how you want the columns totaled and what you want the style of the report to be. Click Finish when you are done.CommentsThe Formula Editor works similarly to other builders, and its pretty straightforward touse. Formulas are another step to making sure you can give your clients the full-featuredreports they want.
Tìm kiếm theo từ khóa liên quan:
công nghệ máy tính phần mềm kỹ thuật lập trình lập trình dữ liệu the Crystal Reports ReportGợi ý tài liệu liên quan:
-
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 266 0 0 -
NGÂN HÀNG CÂU HỎI TRẮC NGHIỆM THIẾT KẾ WEB
8 trang 208 0 0 -
Giới thiệu môn học Ngôn ngữ lập trình C++
5 trang 195 0 0 -
6 trang 192 0 0
-
Bài giảng Nhập môn về lập trình - Chương 1: Giới thiệu về máy tính và lập trình
30 trang 168 0 0 -
Luận văn: Nghiên cứu kỹ thuật giấu tin trong ảnh Gif
33 trang 153 0 0 -
Báo cáo thực tập Công nghệ thông tin: Lập trình game trên Unity
27 trang 118 0 0 -
Giáo trình về phân tích thiết kế hệ thống thông tin
113 trang 114 0 0 -
LUẬN VĂN: Tìm hiểu kỹ thuật tạo bóng cứng trong đồ họa 3D
41 trang 109 0 0 -
Bài giảng Kỹ thuật lập trình - Chương 10: Tổng kết môn học (Trường Đại học Bách khoa Hà Nội)
67 trang 106 0 0 -
Giáo trình Lập trình Web với Servlet và JSP: Phần 1
56 trang 96 0 0 -
Giáo trình Nhập môn lập trình VB6: Phần 2
184 trang 93 0 0 -
Giáo trình Nhập môn lập trình VB6: Phần 1
246 trang 85 0 0 -
Giáo trình toán rời rạc - Phụ lục 2
15 trang 85 0 0 -
Nghiên cứu triển khai nội địa hóa máy tính thương hiệu Việt Nam
585 trang 83 0 0 -
Giáo trình Lập trình hướng đối tượng với Java: Phần 2 - Trần Thị Minh Châu, Nguyễn Việt Hà
141 trang 75 0 0 -
Cách chia sẻ File, dữ liệu mạng Lan trong Windows Xp
10 trang 61 0 0 -
Giáo trình Ngôn ngữ lập trình C++: Phần 2 - TS. Vũ Việt Vũ
107 trang 58 0 0 -
Luận văn: TÌM HIỂU KỸ THUẬT LẬP TRÌNH NETWORK SERVICE CHO WINDOW
39 trang 55 0 0 -
Bài giảng Kỹ thuật lập trình: Chương 7 - Trần Quang
28 trang 52 0 0