如何使用免费的报告生成器FastReport .NTE创建一个新报告

报表生成器FastReport .NET是适用于.NET Core 3,ASP.NET,MVC和Windows窗体的全功能报告库。使用FastReport .NET,您可以创建独立于应用程序的.NET报告。

近日,FastReport .Net升级到v2020.4版,在此版本中,添加了新的条形码:ITF-14和Deutsce Post Identcode,同时优化了多种性能(点击下方按钮下载),感兴趣的朋友可点击下方按钮下载最新版。

点击下载最新版FastReport .Net

Fastreport在线下单立享85折起!赶紧加入购物清单吧!

说到.Net框架,我们通常会想到#C编程语言。仅仅是因为C#程序员的人数众多。但是我们也不应忘记其他语言。例如,来自Stimulsoft的报告生成器的用户希望使用VB.Net语言的应用程序代码创建报告:

“目前,我只是在测试,我想使用VB中的代码创建一个报告。 目前,我试图显示一份我在VB中编写的标题的报告。但不向我显示Web应用程序中的任何内容。

您能否给我一些指导,以指导如何从VB设计报告并显示出来? 或者,如果我省略任何指示或对象来进行报告?”

像允许您从代码创建报告的任何其他报告生成器一样,可以从VB.Net语言的代码中使用Stimulsoft Reports.Net。开发人员已向用户解释了如何执行此操作。

但是,当考虑使用FastReport.Net的某些情况时,实际上我们看不到VB.Net语言中的任何示例。这就是为什么我们要更正本文,并向您展示一个示例,该示例使用VB.Net语言从用户应用程序的代码创建报告。

实际上,它只是C#代码的一种解释:

Dim AppFolder As String
Dim report As New Report() 'create instance of class Report
Dim ds As New DataSet() 'create dataset object

AppFolder = “C:\Users\User\source\repos\VBCodeReport\VBCodeReport\App_Data”
'load data
ds.ReadXml(AppFolder + “\nwind.xml”)
report.RegisterData(ds)
report.GetDataSource(“Products”).Enabled = True
'create report page
Dim page As New ReportPage()
report.Pages.Add(page) 'add created page to report page collection
page.CreateUniqueName() 'with generated name
'create group header band
Dim group As New GroupHeaderBand()
page.Bands.Add(group) 'add the band to band collection
group.CreateUniqueName() 'with generated name
group.Height = Units.Centimeters * 1
group.Condition = “[Products.ProductName].Substring(0,1)” 'set the group condition
group.SortOrder = FastReport.SortOrder.Ascending 'and set sort order
'create text object
Dim groupTxt As New TextObject()
groupTxt.Parent = group 'set the object on whitch the text will be shown
groupTxt.CreateUniqueName()
groupTxt.Bounds = New RectangleF(0, 0, Units.Centimeters * 10, Units.Centimeters * 1) 'set the text object bounds
groupTxt.Text = “[[Products.ProductName].Substring(0,1)]” 'set the text value
groupTxt.Font = New Font(“Arial”, 14, FontStyle.Bold) 'set the font style
groupTxt.VertAlign = VertAlign.Center ’ set the text align
groupTxt.Fill = New LinearGradientFill(Color.LightGoldenrodYellow, Color.Gold, 90, 0.5F, 1) 'set the text object fill
'create data band
Dim data As New DataBand()
group.Data = data 'set the group data
data.CreateUniqueName()
data.DataSource = report.GetDataSource(“Products”) 'set data band source
data.Height = Units.Centimeters * 0.5F 'set data band height
'create one more text object
Dim productText As New TextObject()
productText.Parent = data 'add the text object to data band
productText.CreateUniqueName()
productText.Bounds = New RectangleF(0, 0, Units.Centimeters * 10, Units.Centimeters * 0.5F) 'set the text object bounds
productText.Text = “[Products.ProductName]” 'set the text value
'create group footer band
group.GroupFooter = New GroupFooterBand()
group.GroupFooter.CreateUniqueName()
group.GroupFooter.Height = Units.Centimeters * 1 'set the group footer height
'create total object
Dim groupTotal As New Total()
groupTotal.Name = “TotalRows” 'set total object name
groupTotal.TotalType = TotalType.Count 'set total type
groupTotal.Evaluator = data 'set the band for which the total will be calculated
groupTotal.PrintOn = group.GroupFooter 'set the total place
report.Dictionary.Totals.Add(groupTotal) 'add the total object to totals collection
'create text object
Dim totalText As New TextObject()
totalText.Parent = group.GroupFooter 'set the object on whitch the text will be shown
totalText.CreateUniqueName()
totalText.Bounds = New RectangleF(0, 0, Units.Centimeters * 10, Units.Centimeters * 0.5F) 'set the text object bounds
totalText.Text = “Rows: [TotalRows]” 'set the text value
totalText.HorzAlign = HorzAlign.Right 'set the text align
totalText.Border.Lines = BorderLines.Top 'set the border lines type
report.Show() 'show report
从代码和注释中可以清楚地看到,创建了带有数据分组的报告。但是,此示例显示了简单报表中使用最频繁的对象的工作。请注意,创建报告对象还不够,您仍然需要将其“放置”在要显示它的对象上。这是从代码正确创建报告的关键。
报告生成器FastReport .NET实践指南:使用代码VB.Net创建一个新报告

虽然FastReport Open Source是非常强大的,但仍然有许多限制,你可以点击下方链接查看具体差异。

【功能对比】报表开发工具FastReport Open Source和FastReport .NET都有哪些差异和限制

FastReport Open Source与FastReport .Net间的功能差异还是非常明显的,如果您是企业用户或是需要更完整的功能,建议您直接购买FastReport .Net,盛夏狂欢,在线下单立享85折起!点击查看优惠价格,或咨询在线客服了解详情。
APS帮助提升企业生产效率,真正实现生产计划可视化呈现与控制,快速有效响应不同场景的生产计划,提高准时交货能力,提高产能和资源利用率
想要了解甘特图或慧都APS系统,请登录慧都网咨询在线客服,解决您的问题!
本文章转载自【慧都科技】evget欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,尊重他人劳动成果
原文链接:https://www.evget.com/article/2020/9/29/38484.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值