Autore Topic: Domande su gb.report  (Letto 896 volte)

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.316
  • Ne mors quidem nos iunget
    • Mostra profilo
Domande su gb.report
« il: 20 Settembre 2013, 00:33:40 »
Vi riporto questa discussione apparsa nella mailing list ufficiale:


" I'm working on my first report in Gambas and I'm getting nowhere.
I've been reading that someone took 60 hours to get a grasp on it.
I hope to seriously shorten that time by simply asking here as
documentation is scarce.

My situation very much simplified (it is part of a big migration project
from Windows to Linux with Gambas clients, so I can't really send you a
project).

Table 1 (IC):
ID  |  ProductID  |  RestIC |  ActueelIC

Table 2 (Product):
ProductID  |  Omschrijving

Goal is to make a report with on top field names followed by data.
This field names part needs to be on top of each page.

So the result of the report should look like:

ID      Omschrijving     ActueelIC      RestIC  '<-- this on every page

13    A product    1200        240
12    Other product    2400        2400
...

So there is a header on each page and the body with data.
I have made a report, but have no idea what to put where and how.

On main form this is my code:

Codice: gambas [Seleziona]

Private $hConnTest As New Connection

Public Sub OpenReport()

  Dim rData As Result
  Dim hReport As New RprtIC
  Dim sQuery As String
  sQuery = "SELECT IC.ID, Product.Omschrijving, IC.Actueel.IC, IC.RestIC
from IC LEFT JOIN Product ON IC.ProductID=Product.ProductID ORDER BY
IC.ID DESC

  rData = $hConnTest.Exec(sQuery)
  hReport = New RprtIC($hConnTest, rData)
  hReport.Preview

End


On the report I have this:
Codice: gambas [Seleziona]

Private $hConn As Connection
Private $rResult As Result

Public Sub _new(hConn As Connection, rResult As Result)

  $hConn = hConn
  $rResult = rResult

End


My questions:
1. What objects do I need to draw on the report and where and in what
order?
2. What properties do I need to set on the drawn objects?
3. In what objects do I place what data?

I hope when getting this clear to have some basic insight in reports.

--
Kind regards,

Willy
"


" Gambas report is working like the forms


you need to open a new report

then setup the padding of the report (it's margins)


Add a ReportHBox to create the table header
Set it's height to  1 cm
set the property fixed to true (it repeat the header on each page)

in it add one report label for each column
for each label set the header text
give a width for each of then
set the border for each of them

then

on the report add another reporthbox (name=datalist)
set it's height to 1 cm
in it add a reportlabel for each column (datalabel1, datalabel2, etc)
set theire text to null
set theire width to the same size as those of the header
set theire border

then
in _new

Codice: gambas [Seleziona]

hresult=.....

datalist.datacount=hresult.count


for each datalabel :
example :

Codice: gambas [Seleziona]

Public Sub DataLabel1_data(index as integer)

hResult.Moveto(Index)
Last.Data = hResult!myfield

end


to test the report set it as main class (first launched form of the project)

i give you a demo
(vedi file allegato) with some extra such as page header, title and page footer

you need to play with all the properties to know exactly what they are
doing.

all the array in my example is in an extra vbo with expand to true. it's to
enforce the footer to be at the end of the page even on the last one (when
datas not fill the page)

remember that a report is a multi container i call it sections. you can get
a new section by increase the property count of report. A section is like a
new report (or a new page)

for exemple with that a report can have a title page, a summary, the data ,
the aknowlegement...

gb.report have not a good doc as i've not the time to inprove it. but it's
really powerfull. And since now not so many people use it.

In a short time (some month i will adda grid widget to simplify the simple
table making)

Have fun

Fabien Bodard
"
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.316
  • Ne mors quidem nos iunget
    • Mostra profilo
Re: Domande su gb.report
« Risposta #1 il: 20 Settembre 2013, 18:06:50 »
...continua...


" I never used gb.report because of it's scarce documentation, maybe more
people don't use gb.report for the same reason.
It is a bit of a 'who was first the chicken or the egg' situation:
- Developer doesn't write component docs because of little users
- Users don't use component because of lack of documentation :)

Just a hint: If you would make some comments in the example code on what
you are doing (I mean in the Report Example installed with Gambas), that
could make a world of difference with little effort on your side.

--
Kind regards,

Willy
"
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »