report
Posted
#1
(In Topic #1967)
Trainee

alignement digits
Hello everyone,In the report, I need to enter a name, surname, and address.
The problem is that in the database, some first names have accents, like Félicien and Hélène, etc.
In the report, I can't align the addresses. If there's an accent in the first name, the address is offset by one character.
What font should I use?
Thank you
Sincerely
Posted
Administrator


Hello Leissler,LEISSLER said
In the report,
From “report”, December 11th 2025, 4:39 PM
You could start by clarifying what you mean with report?
Are you creating your own print layout, and what are you using to do so, gb.report2 component maybe?
Generating a document to print data from a database can be achieved in many ways in Gambas.
And if we know what you are using, we still have no idea how you are using it, so an example or excerpt of the code used could help a lot.
Example is better as with gb.report2 there is the layout as well, that can play tricks with you
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Trainee

Yes, it's a report via gb.report2, I think.
Since I can't align two report labels, despite using the `width` and `left` properties, I've only used one.
The problem is that the first names contain accented characters: `:éèçç ç ç^"` etc. The address is shifted to the left by the number of characters containing these accents. For example, in the attached image, the first name "Félicçène" is in the address, and therefore the address is shifted by 3 digits.
If anyone has a solution, I'd be very grateful.
Thank you.
Sincerely from France
Here's the code::
Code
' Gambas class file
Public rs As Result
Public conn As Connection
Public ma_conn_type As String
Public ma_conn_host As String
Public ma_conn_login As String
Public ma_conn_mdp As String
Public ma_conn_database As String = ""
Public rs2 As Result
Public rs3 As Result
Public f As File
Public Sub Report_Open()
ma_connect.main(Me)
conn = New Connection
conn.Type = ma_conn_type
conn.Host = ma_conn_host
conn.Login = ma_conn_login
conn.Password = ma_conn_mdp
conn.Name = ma_conn_database
conn.Open()
rs = conn.Exec("SELECT coalesce(trim(e.nom),30,' ') as nom ,coalesce(trim(e.prenom),25,' ') as prenom ,e.adresse From eleves e LEFT JOIN cotisations c On c.eleves_id = e.id WHERE c.eleves_id Is Null order by e.nom, e.prenom asc")
rs.MoveFirst()
If rs.count > 0 Then
ReportHBox3.DataCount = rs.Count
Endif
End
Public Sub ReportLabelNom_Data(Index As Integer)
If rs.Available = True Then
rs.MoveTo(Index)
If Last Is Null Then Return
Last.Data = padr(Trim(rs!nom), 35, ".") & padr(Trim(rs!prenom), 30, ".") & padr(Trim(rs!adresse), 50, " ")
Endif
End
' Pad à gauche : rajoute le caractère remplac jusqu’à atteindre clong
Public Function padl(chaine As String, clong As Integer, remplac As String) As String
Dim need As Integer
Dim pad As String
need = clong - Len(chaine)
If need <= 0 Then Return chaine
pad = ""
While Len(pad) < need
pad &= remplac
Wend
pad = Left(pad, need)
Return pad & chaine
End
' Pad à droite : rajoute la chaîne "remplac" répétée à droite
Public Function PadR(chaine As String, clong As Integer, remplac As String) As String
Dim need As Integer
Dim pad As String
need = clong - Len(chaine)
If need <= 0 Then Return chaine
pad = ""
While Len(pad) < need
pad &= remplac
Wend
pad = Left(pad, need)
Return chaine & pad
End
Public Sub ReportLabel1_Data(Index As Integer)
If rs.Available = True Then
rs.MoveTo(Index)
If Last Is Null Then Return
Last.Data = padr(Trim(rs!adresse), 50, " ")
Endif
End
Posted
Trainee

I just made this change to my code and it works:
I used string.len to see the difference with len.
Thank you very much. Best regards from France.
Code
' Gambas class file
Public rs As Result
Public conn As Connection
Public ma_conn_type As String
Public ma_conn_host As String
Public ma_conn_login As String
Public ma_conn_mdp As String
Public ma_conn_database As String = ""
Public rs2 As Result
Public rs3 As Result
Public f As File
Public Sub Report_Open()
ma_connect.main(Me)
conn = New Connection
conn.Type = ma_conn_type
conn.Host = ma_conn_host
conn.Login = ma_conn_login
conn.Password = ma_conn_mdp
conn.Name = ma_conn_database
conn.Open()
rs = conn.Exec("SELECT coalesce(trim(e.nom),30,' ') as nom ,coalesce(trim(e.prenom),25,' ') as prenom ,e.adresse From eleves e LEFT JOIN cotisations c On c.eleves_id = e.id WHERE c.eleves_id Is Null order by e.nom, e.prenom asc")
rs.MoveFirst()
If rs.count > 0 Then
ReportHBox3.DataCount = rs.Count
Endif
End
Public Sub ReportLabelNom_Data(Index As Integer)
If rs.Available = True Then
rs.MoveTo(Index)
If Last Is Null Then Return
Dim leprenom, ladresse As String
Dim combien, combienadresse As Integer
leprenom = rs!prenom
If Trim(leprenom) = "féliçiène" Then
Print String.Len(leprenom)
Endif
combien = leprenom.Len - String.Len(leprenom)
combienadresse = ladresse.len - String.Len(ladresse)
Last.Data = padr(Trim(rs!nom), 35, ".") & padr(Trim(rs!prenom), 30 + combien, ".") & padr(Trim(rs!adresse), 50 + combienadresse, " ")
Endif
End
' Pad à gauche : rajoute le caractère remplac jusqu’à atteindre clong
Public Function padl(chaine As String, clong As Integer, remplac As String) As String
Dim need As Integer
Dim pad As String
need = clong - Len(chaine)
If need <= 0 Then Return chaine
pad = ""
While Len(pad) < need
pad &= remplac
Wend
pad = Left(pad, need)
Return pad & chaine
End
' Pad à droite : rajoute la chaîne "remplac" répétée à droite
Public Function PadR(chaine As String, clong As Integer, remplac As String) As String
Dim need As Integer
Dim pad As String
need = clong - Len(chaine)
If need <= 0 Then Return chaine
pad = ""
While Len(pad) < need
pad &= remplac
Wend
pad = Left(pad, need)
Return chaine & pad
End
Posted
Administrator


gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Expert

Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Trainee

Thank you very much.
I will look at this carefully.
Sincerely
Posted
Enthusiast


In my opinion, you shouldn't use just one label.
If you go to the Software Farm, you can download my "ReportTest 0.1.3" example, which can give you an idea of how to use gb.report2.
Here's an explanation (in Italian): Creare report con il componente gb.report2 - Gambas-it.org - Wikipedia
Keep in mind that gb.report2 relies heavily on the design and use of containers.
Posted
Enthusiast

report looks good for that purpouse … but I don't see how it can be used for something like an invoice or packing list with headers with name and address , account number, order date, ship date,then below a list of items order or shipped.
Posted
Enthusiast


gb.Report 2 print only first page - Gambas ONE
be careful, read this post first too:
gb.Report2 example - Gambas ONE
Posted
Administrator


That all can be done with gb.report2.GrayGhost said
I have studied your report 2 .. and think I understand it
report looks good for that purpouse … but I don't see how it can be used for something like an invoice or packing list with headers with name and address , account number, order date, ship date,then below a list of items order or shipped.
From “Post #13,523”, December 15th 2025, 9:40 AM
Main thing about gb.report2 is you need to understand the layout of all containers (as Gianluigi states).
You can make a header section for first page only with this kind of info and a body section that just loops through the data (being a result set of a database or from an array with data).
Once you understand the containers, the layout and how it all fits together, it gets easier to design more complex stuff.
All my reports are work related and with data from a database running on a server. So, I can't really give you an example.
I will address it someday in a guide I will do about databases and reports, but the examples Gianluigi provides should help you form an understanding.
So, focus on the containers, look at the hierachy tab if you study it, to see how all containers relate to each other. Check their properties and what is set and what not.
That is where all is happening.
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Enthusiast

I see it CAN be done …. so I guess I will continue to bang on the keyboard
Please excuse my RANT .
Posted
Administrator


It's okay to blow off some steam if needed, it prevents you from exploding internallyGrayGhost said
I feel like a monkey banging on the keyboard …. since there is no help for any of the controls in the report.
I see it CAN be done …. so I guess I will continue to bang on the keyboard
Please excuse my RANT .
From “Post #13,527”, December 15th 2025, 12:42 PM
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Enthusiast

I need to learn how to put one text field in the middle of the page and say "Hello World" in it .
That is where I started to learn basic and later Gambas
From there I can continue to learn all the fine points of the report2 module.
None of the examples or tutorial show how to do this.
Posted
Administrator


GrayGhost said
I need to learn how to put one text field in the middle of the page and say "Hello World" in it .
From “Post #13,532”, December 15th 2025, 2:36 PM
HelloReport-0.0.1.tar.gz
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Enthusiast

Posted
Enthusiast


GrayGhost said
All the examples that have been suggested is like suggesting I run a 25 K marathon before I have learned to crawl.
I agree with you; I think everyone felt this way, to a greater or lesser extent, at first.
It also depends on one's education; for example, I didn't study algebra, and that really penalizes me.
To be honest, I studied very little, and only passion allows me to understand the little I know about Gambas.
Then I forced myself to study books by gbWilly and Hans Lehman, but I only understood a part of it.
However, I discovered that the more I persisted, the more familiar and understandable things became.
If you want unsolicited advice, I'd load GambOS onto a VM or a partition.
Even an old laptop might work.
Pretend you know nothing and start from scratch.
Gambas has a peculiarity that other languages don't have: containers.
They're a bit tricky because sometimes you're working on one control (containers are also controls) while actually working on another, and this can be confusing.
I say this because it's happened to others, not just me.
Containers allow you to design complex windows in a very short time and without the aid of code, just the right container that arranges the controls within it at the right distance and in the right direction.
gb.report makes extensive use of them; you can view the tests written by its author Fabien Bodard here:
comp/src/gb.report2/.src/Tests · master · Gambas / gambas · GitLab
It would also be helpful to better understand if you attached the System Information, which you can copy from the appropriate window by opening any project in the IDE and clicking on the Help menu, the one with the question mark (?), and then on System Information…
Honestly, I don't know what else to say other than insisting that GambOS is a goldmine of information, both about Gambas and also helps with understanding GNU/Linux.
If you don't believe me, ask yourself why he's been given so much space here.
gbWilly (Willy Raets) is a professional who shares his vast experience; it's up to us to know how to take advantage of it.
1 guest and 0 members have just viewed this.


