[.Net码农]Visual Studio 2012使用水晶报表Crystal Report

本文介绍如何在Visual Studio 2012中使用SAP Crystal Reports创建和显示报表。包括安装Crystal Reports for Visual Studio 2012、创建SQL Server 2012数据库表、编写存储过程及在ASP.NET应用中集成Crystal Report Viewer。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://www.cnblogs.com/insus/archive/2013/05/22/3090786.html

Visual Studio 2012使用水晶报表Crystal Report

SAP在 2013年1月14日 released SAP Crystal Reportsdeveloper version for Microsoft Visual Studio - 2012
你可以从下面链接下载:
http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_13_0_5.exe

下载并安装入你的电脑。安装 完毕,可以看到那些曾经熟悉的工具。


练习练习,算是重温一下使用Crystal report 创建报表的网页。在SQL Server 2012中创建一个表:

复制代码
CREATE TABLE [dbo].[CustomerOrders]
(
    [CO] INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
    [Item] NVARCHAR(40) NOT NULL,
    [Description] NVARCHAR(100) NULL,
    [Unit] NVARCHAR(10),
    [Quantity] INT NOT NULL,
    [Price] DECIMAL(18,4) NOT NULL    
)
GO
复制代码
CustomerOrders


表创建好之后,添加一些记录。

复制代码
INSERT INTO [dbo].[CustomerOrders]
([Item],[Description],[Unit],[Quantity],[Price]) VALUES 
('W023-695-225',N'火星',N'','3','10320.56'),
('W055-641-001',N'土星',N'','2','90000.43'),
('T406-439-226',N'地球',N'','6','23000.81'),
('G071-852-444',N'水星',N'','1','15930.32'),
('U222-476-371',N'木星',N'','8','55179.55')

Go
复制代码
View Code


创建一个存储过程,这个存储过程是获取所有记录,将为水晶报表或是asp.net可用。

CREATE PROCEDURE [dbo].[usp_CustomerOrders_GetAll]
AS
SELECT [CO],[Item],[Unit],[Description],[Quantity],[Price],([Quantity] * [Price]) AS [Amount] FROM [dbo].[CustomerOrders]
GO
usp_CustomerOrders_GetAll

 
在Visual Studio 2012创建一个站点,创建一个网页,拉CrystalReportViewer控件入网页。



拉入CrystalReportviewer控件之后,网页自然产生网页yellow高亮代码。再看看Web.config中添加了哪些代码?



Ok,现在我们要连接数据库了,因此还要配置Web.config,注意一下providerName="System.Data.SqlClient"此句,是为了在CryStal report中连接数据库时,能快速找到数据库。

<connectionStrings>
    <add name="InsusConnectionString" connectionString="Server=127.0.0.1;Initial Catalog=Demo;User ID=Arrot;Password=5236$88;Packet Size=8192;Max Pool Size=1000;" 
         providerName="System.Data.SqlClient"/>
  </connectionStrings>
View Code





接下来,我们在网站下,创建一个CustomerOrders.rpt水晶报表,创建过程,可以参考下列动画:



创建好CryStalReport之后,再来看看web.config添加产生了哪些代码:



去Insus.NET的博客,下载一个DLL,这是一个处理asp.net与SQL Server数据沟通组件。
http://www.cnblogs.com/insus/archive/2010/01/23/1654653.html

解压之后,把DLL移至站点的BIN目录中。

 

然后在App_Code目录,创建一个对象。


 现在,我们可以把CustonerOrders.rpt加载到CryStalReportViewer控件去了:



运行看看:



下面是导出铵钮pop-up窗口:


导出格式丰富多样:


 

7-5 共7个压缩包(只有50M上传权限) Create rich reports within the familiarity of your Visual Studio development environment – for free Hit your report development deadlines and come in under budget without leaving Microsoft Visual Studio. Our report design software installs directly into Visual Studio. With this fully functional – and free software, you'll spend less and save time developing rich, interactive reports. Save time using powerful report creation, integration, and delivery tools Deliver interactive, graphical reports on any device through an XML Web services model Distribute highly formatted reports in rich-client Windows environments Enjoy flexible data access with support for over 35 data sources, major browsers and operating systems Extend your application with seamless report integration into WPF applications Seamless upgrade to SAP Crystal Reports 2011 for added report functionality Download SAP Crystal Reports, developer version for Microsoft Visual Studio now › Share 2 Features and Functionality Collapse All Features and Functionality Learn more about the features and functions of SAP Crystal Reports, developer version for Microsoft Visual Studio. Powerful designer features for creating rich reports Flexible Windows and Web application features support development ASP.NET features support your ASP development efforts Broad data access enables multiple sources and dynamic data output Platform features provide support and management for SAP Crystal Reports projects Get all the details on SAP Crystal Reports, developer version for Microsoft Visual Studio features › Less Technical & License Resources Discover if SAP Crystal Reports, developer version for Microsoft Visual Studio is right for you. Get started by reviewing the technical, data access and license details. Access virtually any data sources via ODBC, OLE DB or native connections Licensed for report design, runtime distribution and report viewer distribution Add reporting to thick client and intern
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值