SQL Server administration and T-SQL development, Web Programming with ASP.NET and Javascript, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software Kodyaz Development Resources
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Vista, etc.




How to Write Text Top to Bottom using Custom Code in SQL Server Reporting Services Reports


Microsoft SQL Server Reporting Services is a flexiable tool for SQL Server Report Developers.
MS SQLServer 2005 SSRS or SQLServer 2008 SSRS Business Intelligence Development Studio (BIDS) gives a handful tools and controls for report developers to build customized reports for their needs.
One of the major tools I apppretiate most is the ability to inject code in your reports. This feature is known as Custom Code in Reporting Services. In the Report Properties dialog screen there exists a tab named Code where you can write custom code for that report.
Now using custom code, I will try to demonstrate how you can write a text or a string value from top to bottom with a sample Reporting Services report.

You now you can arrange the text format in MS SQL Server 2005, using writing mode in the Format tab of the textbox properties.
Or in Microsoft SQL Server 2008 you can alter the writing mode of the text by setting it to vertical.
Or you can use the custome code function SplitTextWithLineBreaks() that I had developed

compare writing mode of string in reporting services





SQL Server 2008 Reporting Services Custom Code Screen

Actually the idea is simple. Split the text into its characters by calling the method ToCharArray() and keep all in a Char() array. Then build a new string by iterating all items in the Character array and adding line breaks using vbCrLf between each character in the string. At last return the resultant text or string back to the caller of the function SplitTextWithLineBreaks()

Public Function SplitTextWithLineBreaks(txt As String) As String

Dim i as integer= 0
Dim returnVal as string = ""
Dim s As Char()

s = txt.ToCharArray

while i < s.Length
   returnVal = returnVal & s(i)
   if i <> s.Length -1 then
      returnVal = returnVal & vbCrLf
   end if
   i = i + 1
end while

return returnVal

End Function

And you can call this custom function by a sample expression like Code.SplitTextWithLineBreaks with the sample code shown below:

= Code.SplitTextWithLineBreaks("SQL Server")

Reporting Services 2008 Writing Mode Vertical







SSRS-Reporting Services

SQL Server Articles

Reporting Services Blog

SQL Server Reporting Services Forums

SQL Blog

Certification Exams Blog



Free Exam Vouchers












Copyright © 2004 - 2011 Eralper Yilmaz. All rights reserved.
Community Server, by Telligent Systems