logo
small logo
  • Ürünler
  • Satın al
  • Yardım
  • About
  • Kullanıcı paneli Yardım
    • en
    • de
    • JP
    • ZH
  • Anasayfa
  • /
  • Articles
  • /
  • Create a new report with code VB.Net
  • How to use Online Designer in ASP .NET Core

    17 Ocak 2018

    One of the novelties by FastReport .NET 2018 was the adaptation of OnlineDesigner to the

    read more
  • FastReport .NET packages and .NET 5.0

    17 Aralık 2020

    UPD: Applies to the versions of FastReport .NET before 2022.2. License packages are now available

    read more
  • Toilet paper printing

    30 Mart 2020

    Gentlemen jokes aside! Today we are talking about toilet paper. This essential hygiene product was

    read more
  • PreviewControl.OnPrint and PreviewControl.OnExport Events

    1 Ekim 2020

    In FastReport 2019.4 added the ability to subscribe to PreviewControl.OnPrint and PreviewControl.OnExport events, which are

    read more
  • How to use the FastReport.Core library from nuget

    20 Mayıs 2018

    UPD: Applies to the versions of FastReport .NET before 2022.2. License packages are now available

    read more

Create a new report with code VB.Net

17 Eylül 2020

Speaking of the .Net framework, we usually imagine the #C programming language. Simply because the share of C# programmers is overwhelming. But we should not forget about other languages as well. For example, a user of the report generator from Stimulsoft wants to create a report from the application code in the VB.Net language:

“…

At this moment I just testing, I would like to create a report with code from VB.

At this moment I am trying to show a report with the tittle that I program in VB. but not show me anything in my web application.

Can you give me some guidance on how to do this would be possible to design the report from VB and it shows?

Or if I'm omitting any instruction or object to make the report?"

https://forum.stimulsoft.com/viewtopic.php?f=8&t=2806

Like any other report generator that allows you to create reports from code, Stimulsoft Reports.Net can be used from code in the VB.Net language. The developers have kindly explained to the user how to do this.

But when we consider some cases of using FastReport.Net, we practically do not see any examples in the VB.Net language. That's why we would like to correct this article and show you an example of creating a report from the code of a user application in the VB.Net language.

In fact, it is only an interpretation of C# code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 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

 It is clear from the code and comments that a report with a grouping of data is created. Nevertheless, this example shows the work with the most frequently used objects in simple reports. Note that it is not enough to create a report object, you still need to "put" it on the object where it will be displayed. This is the key point in correct creation of the report from code.

 Report sample created with VB.Net code

 

ürün hakkında satın al
avatar
Dmitriy Fedyashov
Technical Writer
Fast Reports Team: Dmitriy Fedyashov - Technical Writer at Fast Reports
.NET FastReport Visual Basic

Yorum ekle
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Satın al
  • İndir
  • Dökümantasyon
  • Geribildirimler
  • Ürünlerimizi nasıl kaldırabilirsiniz
  • SSS
  • Başlangıç için Video
  • Forum
  • Support SLA
  • Articles
  • Haberlerimiz
  • Basında Biz
  • Partnerler
  • Extended licensing
  • Bize Ulaşın

© 1998-2023 by Fast Reports Inc.

  • Gizlilik Politikası

Trustpilot