Examples

From DBReport wiki
Jump to: navigation, search

Modify report

RecordSet variable "rs" must be exist.

Dim rpt As New DBReport
 
Dim f as FolderItem= SpecialFolder.Documents.Child("DBReport1.xml")
rpt.LoadXML(f)
rpt.RecordSet= rs
rpt.Designer
rpt.SaveXML(f)

If you want store the definition of report on string variable:

Dim rpt As New DBReport
 
rpt.LoadXML(StringVariable)
rpt.RecordSet= rs
rpt.Designer
StringVariable= rpt.GetXML()

Print report

Dim rpt As DBReport
Dim f as FolderItem= SpecialFolder.Documents.Child("DBReport1.xml")
 
rpt= New DBReport(f, rs)
 
rpt.Print

Preview report

The report and RecordSet must be exist and assign RecordSet to report. Add "DBReportPreview" controlContainer to a window, assign report to controlContainer:

DBReportPreview1.Report(rptVariable)

Other form to use

DBReportDesignerControl and DBReportPreview are ControlContainers, you can place on a Window, set it and used like another control eg. TextField or TextArea.

You can add DBReportDesignerControl to a window and set report with: DBReportDesignerControl1.Report(rpt), you need save the changes with a button with action like: rpt.SaveXML(f). Maybe another button for print.

Also you can create reports by coding:

Dim sRpt As New DBReportSubReport
 
Dim bnd As New DBReportBand
bnd.Name= "PageHeader"
bnd.Type= Int32(DBReportBand.BandType.PageHeader)
sRpt.BandAdd(bnd)
 
Dim ele As New DBReportElement
ele.BandId= bnd.Id
ele.Type= Int32(DBReportElement.ElementType.Label)
ele.Value= "Title"
sRpt.ElementAdd(ele)
 
bnd= New DBReportBand
bnd.Name= "Detail1"
bnd.Type= Int32(DBReportBand.BandType.Detail)
bnd.Height= 20
sRpt.BandAdd(bnd)
 
ele= New DBReportElement
ele.BandId= bnd.Id
ele.Type= Int32(DBReportElement.ElementType.Field)
ele.DataField= "name"
ele.Left= 30
ele.Top= 1
ele.Width= 300
ele.HeightExpand= True
sRpt.ElementAdd(ele)
 
bnd= New DBReportBand
bnd.Name= "PageFooter"
bnd.Type= Int32(DBReportBand.BandType.PageFooter)
bnd.Height= 58
sRpt.BandAdd(bnd)
 
ele= New DBReportElement
ele.BandId= bnd.Id
ele.Type= Int32(DBReportElement.ElementType.Label)
ele.Value= "#pag"
sRpt.ElementAdd(ele)
 
Dim rpt As New DBReport
rpt.SubReportAdd(sRpt)