report

Post

Posted
Rating:
#1 (In Topic #1967)
Avatar
Trainee
LEISSLER is in the usergroup ‘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 Capture d’écran du 2025-12-11 22-23-51.png
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’

LEISSLER said

In the report,
Hello Leissler,

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.  :thumbs:
Example is better as with gb.report2 there is the layout as well, that can play tricks with you  O_o  :lol:

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!
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Trainee
LEISSLER is in the usergroup ‘Trainee’
Hello
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 = &quot;&quot;
  While Len(pad) < need
    pad &= remplac
  Wend

  pad = Left(pad, need)
  Return pad & chaine
End
&#39; Pad à droite : rajoute la chaîne &quot;remplac&quot; 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 = &quot;&quot;
  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, &quot; &quot;)
Endif

End







Capture d’écran du 2025-12-11 22-23-51.png
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by gbWilly)
#4
Avatar
Trainee
LEISSLER is in the usergroup ‘Trainee’
Hello again everyone.
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.

Capture d’écran du 2025-12-12 11-03-37.png

Code

&#39; 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 = &quot;&quot;
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(&quot;SELECT coalesce(trim(e.nom),30,&#39; &#39;) as nom  ,coalesce(trim(e.prenom),25,&#39; &#39;) 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&quot;)
  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) = &quot;féliçiène&quot; 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, &quot;.&quot;) & padr(Trim(rs!prenom), 30 + combien, &quot;.&quot;) & padr(Trim(rs!adresse), 50 + combienadresse, &quot; &quot;)
Endif
End



  &#39; 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 = &quot;&quot;
  While Len(pad) < need
    pad &= remplac
  Wend

  pad = Left(pad, need)
  Return pad & chaine
End
&#39; Pad à droite : rajoute la chaîne &quot;remplac&quot; 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 = &quot;&quot;
  While Len(pad) < need
    pad &= remplac
  Wend

  pad = Left(pad, need)
  Return chaine & pad
End







 
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’
I was just trying to create a little example, but you got it going  :thumbs:

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!
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Expert
Quincunxian is in the usergroup ‘Expert’
Also, I'd have a look at the String.PadLeft & String.PadRight frunctions.
They are part of Gb.Util 
 

Cheers - Quin.
I code therefore I am
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Trainee
LEISSLER is in the usergroup ‘Trainee’
Very interesting and informative.

Thank you very much.
I will look at this carefully.

Sincerely
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by gbWilly)
#8
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
Gianluigi is in the usergroup ‘GambOS Contributor’
LEISSLER
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.

 :goodbye:
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
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.
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by gbWilly)
#10
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
Gianluigi is in the usergroup ‘GambOS Contributor’
Here, you can find another example that can help:
gb.Report 2 print only first page - Gambas ONE
be careful, read this post first too:
gb.Report2 example - Gambas ONE

 :goodbye:
Online now: No Back to the top

Post

Posted
Rating:
#11
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’

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.
That all can be done with gb.report2.:thumbs:

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!
Online now: No Back to the top

Post

Posted
Rating:
#12
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
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 .  
Online now: No Back to the top

Post

Posted
Rating:
#13
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’

GrayGhost 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 .  

It's okay to blow off some steam if needed, it prevents you from exploding internally :lol:
 

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!
Online now: No Back to the top

Post

Posted
Rating:
#14
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
All the examples that have been suggested is like suggesting I run a 25 K marathon before I have learned to crawl.

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.
 
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by sholzy)
#15
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’

GrayGhost said

I need to learn how to put one text field in the middle of the page and say "Hello World" in it .
Attachment

HelloReport-0.0.1.tar.gz



 :thumbs:

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!
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by gbWilly)
#16
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
THANK YOU very much ... that is exactly what I need .
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by gbWillyLiked by Yogi)
#17
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
Gianluigi is in the usergroup ‘GambOS Contributor’

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.
Online now: No Back to the top
1 guest and 0 members have just viewed this.