in app.open:
[code]
Valentina.InitReports( “”, “VR4RB-W-XXXXX…”, “VR4RB-L-XXXXXXXXX” ) //Your ADK serial numbers
[/code ]
in app. close:
[code]
Valentina.ShutDown
[/code ]
create the following method:
[code]
Sub mConfiguraReporte(NombreProyecto as string, NombreReporte as string, SQL as String)
dim i As Integer
dim repName, pathDB as String
Dim count As Integer
dim f as FolderItem
Dim wIndiceReporte As Integer
dim mProject as VProject
dim mProjectPath as FolderItem
dim mReport as VReport
wIndiceReporte=1
#if TargetWin32 then
dim db_lite_location as FolderItem = GetFolderItem( “c:\reportes\reportes.db” )
#else
dim db_lite_location as FolderItem = GetFolderItem( “//home/reportes/reportes.db” )
#endif
dim db_lite_path as string = db_lite_location.ShellPath
db_lite_path = ReplaceAll( db_lite_path, "\ ", " " )
// Produce datasource-string
dim ds_str as string = “sqlite://” + db_lite_path
f=getfolderItem(NombreProyecto)
mProjectPath = f
if f <> nil then
mProject = new VProject(mProjectPath)
mProject.Open()
if mProject <> nil then
count = mProject.ReportCount()
for i = 1 to count
repName = mProject.ReportName(i)
if repName= NombreReporte then wIndiceReporte=i
next i
end if
else
return
end if
try
mReport = mProject.MakeNewReport(wIndiceReporte, ds_str , SQL)
catch e as VException
end
if mReport <> nil then
Dim res As Boolean
if mReport <> nil then
#if TargetLinux then
f=GetFolderItem("//home/reports/"+nombrereporte+".pdf",0)
if f.Exists then
f.Delete
f=GetFolderItem("//home/reports/"+nombrereporte+".pdf",0)
end if
#else
f=GetFolderItem(“c:\reports”+nombrereporte+".pdf",0)
if f.Exists then
f.Delete
f=GetFolderItem(“c:\reports”+nombrereporte+".pdf",0)
end if
#endif
if f <> nil Then
mReport.PrintToDisk( f, EVReportPrintType.kToPDF, 1 )
// f.Launch // if you want show PDF preview
sh=new Shell
sh.Mode=0
If TargetWin32 Then
sh.Execute(“c:\reports\sumatrapdf.exe -print-to-default c:\reportes” +NombreReporte+".pdf") //needs sumatrapdf.exe free download to direct print in Windows
else
sh.Execute “lp //home/reports/”+NombreReporte+".pdf"
End if
If sh.errorCode <> 0 then
MsgBox "Error al imprimir: " + Str(sh.errorCode)
end if
sh.Close
end if
end if
end if
End Sub
[/code ]
Finally call the method from a button action or anything else
[code]
// change with your valentina project name, report name and respective query
#if TargetWin32 then
mConfigurarReporteLocal(“C:\reports\yourprojectname.vsp”,“yourreportname”,“SELECT * FROM XXX”)
#else
mConfigurarReporteLocal("//home/reports/yourprojectname.vsp",“yourreportname”,“SELECT * FROM XXX”)
#endif
[/code ]