Wednesday 14 November 2012

SSRS:Export to Excel in Individual tabs

 ' Returns a properly formatted list of comma seperated marks
    ' Assumes that the input list is a list of comma seperated values
    ' Adds single quotes around each value and then joins them back together
    Public Function FormattedCommaSeperatedList(ByVal pCommaSeparatedString As String) As String       
        Dim sTokens As String() = pCommaSeparatedString.Split(",")
        Dim iTokenCount As Integer = 0
        FormattedCommaSeperatedList = ""
        If sTokens.Length > 1 Then
            Dim sToken As String
            For Each sToken In sTokens
                'for each token, concat with the single quote and put back into output string
                FormattedCommaSeperatedList = FormattedCommaSeperatedList + "'" + Trim(sToken) + "'"

                If iTokenCount < sTokens.Length - 1 Then
                    FormattedCommaSeperatedList = FormattedCommaSeperatedList + ","
                End If
                iTokenCount = iTokenCount + 1
            Next

        Else
            FormattedCommaSeperatedList = FormattedCommaSeperatedList + "'" + sTokens(0) + "'"
        End If
    End Function