Problem: How to create a custom
function to format the body or text box to use inside an expression in SSRS?
Solution: Add
Code to a Report
Sometimes when you want to create a custom action inside a
text box to fill an expression based formatting.
n any expression, you can call your own custom code.
You can provide code in the following two ways:
·
Embed code written in Visual Basic directly in your
report. If your code refers to a Microsoft .NET Framework that is not or , you must add the reference to the
report. For more information, see .
For more information about other references you can make from your code, see .
·
Provide a custom code assembly by using the .NET
Framework. If you provide a custom assembly, you must install it on both the
computer where you author the report and the report server where you view the
report. For more information, see .
Example:
In this article, I am going to show we can use a report data
column to set alternative color in the rows report based on auto incremented
number.
Step 0:
Create an invoice detail report using the below set
SELECT
orderID
[Invoiceid]
,[itemid]
,[unitprice]
,[quantity]
,[TotalAmount]
,[lineitem]
,[linetotal]
,[invoicedate]
FROM [dbo].[OrderInvoice]
ORDER BY
ORDERID asc
Step 1: Go
to the designer, right click outside of the report body to get report
properties
Step 2: from the report properties in the code tab add a function to give alternative color based on ordered column.
Step 3:
From the report data column go to the text box properties option.
Step 4: from
the text properties options click on the fill to set the expression for filling
the color.
Step 5:
Repeat this to all the textbox properties and execute the report.
Results:
0 comments:
Post a Comment