Stimulsoft Reports.Net示例演示:在WinForms 类别中在运行系统中创建一个简单的报告

发布时间 : 2021-09-14 10:35:56.970|阅读 91 次

概述:此示例显示如何在运行系统中创建一个简单的报告。让我们创建包含标题、数据、总计的报告并将其显示在查看器中。

相关链接:

Stimulsoft Ultimate是用于创建报表和仪表板的通用工具集。该产品包括用于WinForms、ASP.NET、.NET Core、JavaScript、WPF、PHP、Java和其他环境的完整工具集。

Stimulsoft Reports不仅拥有强大的报表导出系统,而且还支持多种报表导出格式,拥有简单且强大的报表引擎。Stimulsoft Reports基本原则是,用简单常规的方法创建报表,将不同的技术应用于应用程序。Stimulsoft Reports ..NET一个基于.NET框架的报表生成器,能够帮助你创建结构、功能丰富的报表。不仅界面友好,而且使用便捷,能够让你轻松创建所有报表。

点击下载Stimulsoft Reports .NET v2021.3.1最新版

此示例显示如何在运行系统中创建一个简单的报告。让我们创建包含标题、数据、总计的报告并将其显示在查看器中。首先,创建一个新报告并将数据源添加到字典中:

private void button1_Click(object sender, System.EventArgs e)
{
	StiReport report = new StiReport();
	
	// Add data to datastore
	report.RegData(dataSet1);
	
	// Fill dictionary
	report.Dictionary.Synchronize();
	
	StiPage page = report.Pages[0];

...

添加带有文本框的标题带并为其分配数据标题:

...

	// Create HeaderBand
	StiHeaderBand headerBand = new StiHeaderBand();
	headerBand.Height = 0.5;
	headerBand.Name = "HeaderBand";
	page.Components.Add(headerBand);
	
	// Create text on header
	StiText headerText = new StiText(new RectangleD(0, 0, 5, 0.5));
	headerText.Text = "CompanyName";
	headerText.HorAlignment = StiTextHorAlignment.Center;
	headerText.Name = "HeaderText";
	headerText.Brush = new StiSolidBrush(Color.LightGreen);
	headerBand.Components.Add(headerText);

...

接下来,添加一个带有文本框的数据带,其中包含对数据字段的引用:

...

	// Create Databand
	StiDataBand dataBand = new StiDataBand();
	dataBand.DataSourceName = "Customers";
	dataBand.Height = 0.5;
	dataBand.Name = "DataBand";
	page.Components.Add(dataBand);
	
	// Create text
	StiText dataText = new StiText(new RectangleD(0, 0, 5, 0.5));
	dataText.Text = "{Line}.{Customers.CompanyName}";
	dataText.Name = "DataText";
	dataBand.Components.Add(dataText);

...

接下来,添加一个带有文本框的数据带,其中包含对数据字段的引用:

...

	// Create Databand
	StiDataBand dataBand = new StiDataBand();
	dataBand.DataSourceName = "Customers";
	dataBand.Height = 0.5;
	dataBand.Name = "DataBand";
	page.Components.Add(dataBand);
	
	// Create text
	StiText dataText = new StiText(new RectangleD(0, 0, 5, 0.5));
	dataText.Text = "{Line}.{Customers.CompanyName}";
	dataText.Name = "DataText";
	dataBand.Components.Add(dataText);

...

接下来,添加一个带有文本框的页脚带,其中包含数据总计的函数:

...

	// Create FooterBand
	StiFooterBand footerBand = new StiFooterBand();
	footerBand.Height = 0.5;
	footerBand.Name = "FooterBand";
	page.Components.Add(footerBand);
	
	// Create text on footer
	StiText footerText = new StiText(new RectangleD(0, 0, 5, 0.5));
	footerText.Text = "Count - {Count()}";
	footerText.HorAlignment = StiTextHorAlignment.Right;
	footerText.Name = "FooterText";
	footerText.Brush = new StiSolidBrush(Color.LightGreen);
	footerBand.Components.Add(footerText);

...

最后,在查看器中显示一个报告:

...

	report.Show();
}

在下面的屏幕截图中,您可以看到示例代码的结果:

Stimulsoft Reports.Net示例演示:在WinForms 类别中在运行系统中创建一个简单的报告

Aspose、E-iceblue、FastReport、Stimulsoft等文档/报表图表类开发工具享超低折扣,如有需要可直接联系在线客服


在线
客服
微信
QQ 电话
023-68661681
返回
顶部