Register a custom function in a report
Register a custom function in a report
Hello.
We have included a custom function directly in the report code:
Public Class Report
Inherits Stimulsoft.Report.StiReport
Public Sub New()
MyBase.New
Me.InitializeComponent
End Sub
Public Function EN(palabra As String, listaPalabras As list(Of String)) As Boolean
For Each key As String In listaPalabras
If palabra = key Then
Return (True)
Else
Return (False)
End If
Next
End Function
#Region "StiReport Designer generated code - do not modify"
#End Region 'StiReport Designer generated code - do not modify
End Class
Can we include and register this function in the functions dictionary of the report?. Can you provide to us a sample of how to do it?
Thank you.
We have included a custom function directly in the report code:
Public Class Report
Inherits Stimulsoft.Report.StiReport
Public Sub New()
MyBase.New
Me.InitializeComponent
End Sub
Public Function EN(palabra As String, listaPalabras As list(Of String)) As Boolean
For Each key As String In listaPalabras
If palabra = key Then
Return (True)
Else
Return (False)
End If
Next
End Function
#Region "StiReport Designer generated code - do not modify"
#End Region 'StiReport Designer generated code - do not modify
End Class
Can we include and register this function in the functions dictionary of the report?. Can you provide to us a sample of how to do it?
Thank you.
Re: Register a custom function in a report
Hello,
Please check the following code:
Thnak you.
Please check the following code:
Code: Select all
Public Class MyFunction
Private Const Category As String = "MyFuncCategory"
Public Shared Function MyFunc(value As String) As String
Return value.ToUpper()
End Function
Public Shared Sub RegisterFunctions()
Dim ParamNames = New String(0) {}
Dim ParamTypes = New Type(0) {}
Dim ParamDescriptions = New String(0) {}
ParamNames(0) = "value"
ParamDescriptions(0) = "Descriptions"
ParamTypes(0) = GetType(String)
Stimulsoft.Report.Dictionary.StiFunctions.AddFunction(Category, "MyFunc", "MyFunc", "Description", GetType(MyFunction), GetType(String),
"Return Description", ParamTypes, ParamNames, ParamDescriptions)
End Sub
End Class
- Attachments
-
- Capture.PNG (52.9 KiB) Viewed 6946 times
Re: Register a custom function in a report
Hello,
I have the same problem, in a new report I copied your code and I get an error "referencedAssemblies" .
I attaching the Mrt and a screenshot of the error (Sorry the screenshot are in spanish)
Might you help me?
Thank you
I have the same problem, in a new report I copied your code and I get an error "referencedAssemblies" .
I attaching the Mrt and a screenshot of the error (Sorry the screenshot are in spanish)
Might you help me?
Thank you
- Attachments
-
- Screenshot error
- 2016-09-21_11-55-13.png (19.69 KiB) Viewed 6945 times
-
- test.mrt
- Report test
- (4.19 KiB) Downloaded 252 times
Re: Register a custom function in a report
Hello,
We have found the issue with adding a custom function when selected VB script language for the report.
The issue is fixed. Will be available in the next prerelease build.
At the current moment, you can use the several ways:
- add this code for adding function to your application, not in the designer's Code tab
- select CSharp script language (attached report ReportC.mrt)
Thank you.
We have found the issue with adding a custom function when selected VB script language for the report.
The issue is fixed. Will be available in the next prerelease build.
At the current moment, you can use the several ways:
- add this code for adding function to your application, not in the designer's Code tab
- select CSharp script language (attached report ReportC.mrt)
Thank you.
- Attachments
-
- ReportC.mrt
- (4.08 KiB) Downloaded 444 times
Re: Register a custom function in a report
Hello,
Also, please check the modified report with VB script.
Thank you.
Also, please check the modified report with VB script.
Thank you.
- Attachments
-
- ReportVb2.mrt
- (4.35 KiB) Downloaded 554 times
Re: Register a custom function in a report
Thanks, We'll wait for this issue fixed in the next build.Aleksey wrote:Hello,
We have found the issue with adding a custom function when selected VB script language for the report.
The issue is fixed. Will be available in the next prerelease build.
At the current moment, you can use the several ways:
- add this code for adding function to your application, not in the designer's Code tab
- select CSharp script language (attached report ReportC.mrt)
Thank you.
This example if it works, but I still can add the function to the dictionary, is not visibleAleksey wrote:Hello,
Also, please check the modified report with VB script.
Thank you.
Thanks for you help, and I hope that the next build work
- Attachments
-
- 2016-09-21_17-31-51.png (3.5 KiB) Viewed 6942 times
Re: Register a custom function in a report
Hello,
Yes. In the EndRender event, this function is removed.
Please check the next build.
Thank you.
Yes. In the EndRender event, this function is removed.
Please check the next build.
Thank you.
Re: Register a custom function in a report
Hi Alex,
Starting from which version/build should this be solved?
Thanks for answering,
Leen
Starting from which version/build should this be solved?
Thanks for answering,
Leen
Re: Register a custom function in a report
Hi Alex,
Starting from which version/build should this be solved?
Thank you.
Starting from which version/build should this be solved?
Thank you.
-
- Posts: 6247
- Joined: Tue Mar 20, 2018 5:34 am
Re: Register a custom function in a report
Hello,
Starting from 2016.3
Thank you.
Starting from 2016.3
Thank you.