Is there a way to use the split function in a report

Stimulsoft Reports.NET discussion
Post Reply
mdavidson
Posts: 4
Joined: Thu May 21, 2009 10:27 am
Location: USA

Is there a way to use the split function in a report

Post by mdavidson »

I have a field in a bussiness object in my Data Dictionary that is a comma delimited list of numbers.
Is there a way in the report code to do something like
tempStr = Split({FanGroup.Sound_PowerLevelsOutlet}, ",")
so I can display text as tempStr(0),tempStr(1),tempStr(2) etc.
mdavidson
Posts: 4
Joined: Thu May 21, 2009 10:27 am
Location: USA

Is there a way to use the split function in a report

Post by mdavidson »

I'm sorry, but I figured out a way.
I added a function to the code of the report

Public Class Report
Inherits Stimulsoft.Report.StiReport

Public Function ExtractValue(aString As String,aPlace As Integer) As String
Dim retStr As String = String.Empty
Dim tempStr() As String
tempStr = aString.Split(",")
If tempStr.Length > aPlace Then
retStr = tempStr(aPlace)
End If
Return retStr
End Function

... And then from a text component I can add the expression

{ExtractValue(FanGroups.SoundPowerLevelsInlet,0)}
chad
Posts: 4
Joined: Fri Jan 08, 2010 12:59 pm
Location: USA

Is there a way to use the split function in a report

Post by chad »

Here is how I did it

Code: Select all

    	// custom functions
		public string SplitString(string rsString, string rsDelimiter, int riItem) {
			if (rsString.Contains(rsDelimiter)) {
				return rsString.Split(rsDelimiter.ToCharArray())[riItem];			
			} else {
				return rsString;
			}
		}
Post Reply