Page 1 of 1

Can´t get value of report variable from code

Posted: Mon Mar 13, 2017 4:16 pm
by luis073094
My problem is this:
I have a project where a report is loaded from string via code vb,

Code: Select all

Dim reporte as New StiReport
reporte.LoadFromString(definition)
This report has a variable whose value changes in the EndReport event, then when I retrieve that variable value via code in my project this is empty.

Code: Select all

Dim counter as String

reporte.Render(False)
counter = reporte.Dictionary.Variables.Item("counter").Value
'Value of counter is "" but in report code is 415
Not only this variable, also any other property of the rendered report, for example:

Code: Select all

Dim empty as Boolean

reporte.Render(False)
empty = reporte.DataSources.Item(0).IsEmpty
'empty is true, but the report contains data :(
I also try to change the report name from the Report event: EndRender, but when I export it, it's show me the defaul name.

Code: Select all

'In report code
Public Sub Informe_BeginRender(ByVal sender As Object, ByVal e As System.EventArgs)
           Me.ReportAlias="Test1"
           Me.ReportName="Test1"
End Sub

'Then in my code
Dim reporte as New StiReport
reporte.LoadFromString(definition)
reporte.Render(False)
reporte.SavePackedDocument(nameFile)
In nameFile file says:

Code: Select all

<ReportName>Report</ReportName> --> Should be "Test1"
<ReportAlias>Report</ReportAlias>   --> Should be "Test1"
Note: I'm rendering the report in server and show it on client side. I'm using 2016.2 version

Re: Can´t get value of report variable from code

Posted: Wed Mar 15, 2017 1:14 pm
by Alex K.
Hello,

Please clarify how do you set the value for the variable in the end render event?

Thank you.

Re: Can´t get value of report variable from code

Posted: Fri Mar 17, 2017 3:20 pm
by luis073094
Changing report name:
In Report:
Image

In Code:
Image

Changing "correlativo" value:
In report:
Image

In Code:
Image

Re: Can´t get value of report variable from code

Posted: Mon Mar 20, 2017 7:48 am
by HighAley
Hello.

The report template class is not changed during the rendering process.
There is CompiledReport that you should check.
ReportName.png
ReportName.png (2.91 KiB) Viewed 1834 times
Thank you.