Custom Reporting Library
A Dynamic Link Library (DLL) named CrowsNest.Reporting.dll is provided which has some functions used to extend the reporting functionality in MS Report Builder.
The library is included in the installation directory where Crows Nest is installed (typically C:\Program Files (x86)\Crows Nest).
To preview reports that use the library from within Report Builder, you’ll need to copy the DLL file into the installation directory for Report Builder (typically C:\Program Files (x86)\Microsoft Report Builder)
To utilize the functions, open a report in Report Builder and follow the steps below:
Add a Reference to the library
Open Report Properties
Select References
Under ‘Add or remove assemblies’ click Add
On the newly added reference record click the … button to browse to the CrowsNest.Reporting.dll file and click Open
Click OK to close Report Properties
Add Code to the report
Open Report Properties
Select Code
Add a Function using VB .NET syntax to call the function from the library
Example:Function PadLeft(imgBytes, cellWidth, cellHeight, centered)
Return CrowsNest.Reporting.Images.PadLeft(imgBytes, cellWidth, cellHeight, "in", centered)
End Function
Click OK to close Report Properties
Add Expression to call the Code
Edit any Expression and Reference the Code
Example:=Code.PadLeft(Fields!Logo.Value, 2.5, 1, True)
Available Functions
Combine the header below with the function name to reference the function in Code
Example: CrowsNest.Reporting.Strings.HTML_BulletedList
Strings
HTML_BulletedList - Process text into a bulleted list using HTML syntax. To have the HTML rendered in the report, open Placeholder Properties for the Placeholder using this code and change Markup type to ‘HTML’. If the Header parameter is supplied it will look for a header in the text provided in the Value parameter for a header surrounded by double square brackets and will return only the text between that header and the next header found or the end of the text if a subsequent header is not found.
HTML_BulletedList(Value as String, Delimiter as String, Optional Header as String) as String
Example:Text in Value Parameter
[[Exclusions]] Applicable sales taxes All Electrical, Plumbing, HVAC [[Notes]] This Proposal becomes part of a contract document This proposal is valid for 30 days.
Function reference in Code
CrowsNest.Reporting.String.HTML_BulletedList(Fields!LongDescription.Value, Environment.NewLine, “Exclusions”)
Result
<ul> <li>Applicable sales taxes</li> <li>All Electrical, Plumbing, HVAC</li> </ul>
JoinNonNull - Join an array of objects to a string with a delimiter, excluding any empty values.
JoinNonNull(Values() as Object, Optional Delimeter as String = "") as String
Images
PadLeft - Calculate a Left Padding value to horizontally align a database image to center or right. To align right change CenterImage parameter to False.
PadLeft(imgBytes As Byte(), cellWidth As Double, cellHeight As Double, Optional UnitOfMeasure As String = "in", Optional CenterImage As Boolean = True) As String
PadTop - Calculate a Top Padding value to vertically align a database image to center or bottom. To align bottom change CenterImage parameter to False.
PadTop(imgBytes As Byte(), cellWidth As Double, cellHeight As Double, Optional UnitOfMeasure As String = "in", Optional CenterImage As Boolean = True) As String
ColorToHex - Get a hexadecimal color string from a String or a System.Drawing.Color
ColorToHex(c as Drawing.Color) as String ColorToHex(s as String) as String
Example Expressions
=Code.ColorToHex(Fields!BackColor.Value) =Code.ColorToHex("255,255,255")
StringToColor - Get a System.Drawing.Color from a color string
StringToColor(strColor as String, Optional defaultColor as Object = Nothing) as System.Drawing.Color
QRCode - Generate a QRCode image as a byte array to display in an Image object.
QRCode(content As String, size As Integer, Optional logofilepath As String = "", Optional IsURL As Boolean = False, Optional darkcolor As String = "", Optional lightcolor As String = "") As Byte()
The following overload accepts a logo image in a byte array instead of a logo filepath
QRCode(content As String, size As Integer, logobytes As Byte(), Optional IsURL As Boolean = False, Optional darkcolor As String = "", Optional lightcolor As String = "") As Byte()
See the following explanation for each of the arguments
content = Text content of the QRCode
size = Pixels per module. Large values here can cause out-of-memory errors from the report viewer.
logofilepath = Filepath to a logo to embed in the center of the QR Code (example: C:\\myimage.png)
logobytes = Byte array of logo to embed in the center of the QR Code. This can be an image field from a dataset (example: Fields!Logo.Value)
IsURL = True if the content is a web URL to format the QR Code as a URL Payload
darkcolor = Dark color in the QR Code (examples: “black”, “255,255,255”)
lightcolor = Light color in the QR Code (examples: “white”, “0,0,0”)
Example
Expression (Value property on an Image with Source set to Database)
=Code.QRCode("www.crowsnestsoftware.com", 20, "", True, "Red", "White")
Code
Function QRCode(content as String, size as Integer, logobytes as Byte(), Optional IsUrl as Boolean = False, Optional darkcolor as String = "", Optional lightcolor as String = "") Return CrowsNest.Reporting.Images.QRCode(content, size, logobytes, IsURL, darkcolor, lightcolor) End Function
Timeline
TimelineHeaderImage - Returns an image for the header cell including year/month/day to mimic the header of the timeline view in Tasks.
TimelineHeaderImage(width As Integer, height As Integer, objMinDate As Object, objMaxDate As Object, RowColor As String, DaySeparatorColor As String, MonthSeparatorColor As String, FontName As String, FontSize As String, FontColor As String, WeekendFontColor As String, Optional DayNameLength As Integer = 1) As Byte()
Example
Expression
=Code.TimelineHeaderImage(Variables!CellWidthPixels.Value, Variables!HeaderHeightPixels.Value, First(Fields!PeriodStart.Value, "Tasks"), First(Fields!PeriodEnd.Value, "Tasks"))
Code
Function TimelineHeaderImage(width, height, minDate, maxDate) As Byte() Dim rowColor as string = "" Dim daySeparatorColor as string = "" Dim monthSeparatorColor as string = "SkyBlue" Dim fontSize as string ="10" Dim fontName as string = "Arial" DIm fontColor as string = "" Dim fontColorWeekend as string = "SkyBlue" Dim dayNameLength as integer = 1 Dim t as new CrowsNest.Reporting.Timeline Return t.TimelineHeaderImage(width, height, minDate, maxDate, rowColor, daySeparatorColor, monthSeparatorColor, fontName, fontSize, fontColor, fontColorWeekend) End Function
TimelineRowImage - Returns an image for the data row cell to mimic the the data rows of the timeline view in Tasks. Available values for the MarkerType parameter are Diamond, Triangle, Circle and Square (not case sensitive).
TimelineRowImage(width As Integer, height As Integer, objMinDate As Object, objMaxDate As Object, startDate As Object, endDate As Object, RowColor As String, DaySeparatorColor As String, MonthSeparatorColor As String, FillColor As String, BorderColor As String, HatchColor As String, HatchPattern As Object, strLabel As String, FontName As String, FontSize As String, FontColor As String, Optional MarkerType As String = "", Optional MarkerSize As Integer = 0, Optional Progress As Decimal = 0, Optional WeekendBackColor As String = "", Optional AlternateDayColor As String = "") As Byte()
Example
Expression
=Code.TimelineRowImage(Variables!CellWidthPixels.Value, Variables!CellHeightPixels.Value, First(Fields!PeriodStart.Value, "Tasks"), First(Fields!PeriodEnd.Value, "Tasks"), Fields!StartDate.Value, Fields!DueDate.Value, Fields!FillColor.Value, Fields!BorderColor.Value, Fields!PatternColor.Value, Fields!FillPattern.Value, Fields!Label.Value)
Code
Function TimelineRowImage(width, height, minDate, maxDate, startDate, endDate, FillColor, BorderColor, HatchColor, HatchPattern, strLabel) As Byte() Dim rowColor as string = "" Dim daySeparatorColor as string = "Transparent" Dim monthSeparatorColor as string = "SkyBlue" Dim fontSize as string ="10" Dim fontName as string = "Arial" DIm fontColor as string = "" Dim fontColorWeekend as string = "" Dim markerType as String = "" 'Diamond, Square, Circle, Triangle Dim markerSize as Integer = 16 Dim wkndColor as String = "Tan" Dim altBackColor as String = "WhiteSmoke" Dim progress as Double = 0 Dim t as new CrowsNest.Reporting.Timeline Return t.TimelineRowImage(width, height, minDate, maxDate, startDate, endDate, rowColor, daySeparatorColor, monthSeparatorColor, FillColor, BorderColor, HatchColor, HatchPattern, strLabel, fontName, fontSize, fontColor, markerType, markerSize, progress, wkndColor, altBackColor) End Function