You must Sign In to post a response.
  • Category: SQL Server

    Bold, Italic and normal in SSRS report

    How to set text styles such as bold, italic or normal for a textbox in SSRS reports by using expression?
  • #765995

    HI,
    Use IIF() statement as a expression for the textbox as follows:

    Select the textbox==> Open its property window==> Font==> FontWeight and expand it and put an expression somewhat like :
    =IIF(SomeCondition,"Bold","Normal")
    =IIF(Fields!ColumnXYZ.Value <> "SomeValue", "Italic", "Normal")

    Also go through this for more details:
    http://www.sqlchick.com/entries/2010/10/31/using-different-formats-within-a-single-textbox-in-ssrs.html

  • #766007
    will assume when you say RDL, you have referring to an SSRS Report file. If you are running this RDL file in 2005, you cannot do this cleanly, you could split the column into 3 columns and bold the middle column that contains "Queue" but that is messy and ugly. If you are using 2008 there are a couple ways to do it, the easiest would be to:
    1.Click into the text box (so your cursor is in the text box)
    2.Right Click and select "CREATE PLACEHOLDER"
    3.In Markup Type select "HTML - Interpret HTML tags as styles"
    4.In Value:="This is a <b>Queue</b> Builder"
    ok, you are done with it

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #766028
    Hi,

    Let's say you want to mix formats of a single textbox on a SQL Server Reporting Services report, as follows:

    SplitFormatting_Heading

    Different formats could include mixing font sizes, colors, and other things like bold and italics within one textbox. The easiest way to handle different formatting is to split it into 2 textboxes. However, you may have a need to stay within one textbox depending on the string that needs to be concatenated, or to avoid alignment issues with other textboxes. Within one textbox, I've found 3 ways to format specific text, numbers, fields, or expressions:

    1. Selected Text Properties

    2. Placeholder Properties and Text Properties Panes

    3. HTML Tags (which also involves Placeholder Properties)

    The remainder of this entry discusses each of the 3 methods. This technique applies only to SSRS 2008, R2, and Report Builder 3.0. SSRS 2008 R2 is used for the examples shown.

    Selected Text Properties
    This is the most straightforward technique, and should be familiar as it's used throughout many Microsoft applications. After you highlight a portion of the textbox, you may use the toolbar or the Properties Pane which will have "Selected Text" as the object name. The key to making this work is you need a simple expression, rather than a complex expression in the design view (i.e., make sure the design view does not show just <Expr> for the entire textbox - within part of it is okay though - see "A Word About <Expr>" toward the end of this entry).

    SplitFormatting_HighlightText

    Note that after mixed formatting is applied, if you right-click the textbox, the Expressions option is no longer available:

    SplitFormatting_NoExprOption

    Next let's get into the more interesting capabilities.

    Placeholder Functionality
    Placeholders were introduced in SSRS 2008 to accomplish the very goal we have. As with the previous technique, this relies on a simple expression, rather than a complex expression in the design view (i.e., make sure the design view does not show just <Expr> for the entire textbox - within part of it is okay though - see "A Word About <Expr>" toward the end of this entry). A simple expression will show our sample field as [@ParamQtrEnd] instead of =Parameters!ParamQtrEnd.Value. More information on simple versus complex expressions can be found in the Understanding Simple and Complex Expressions article on MSDN.

    Just where are Placeholder Properties? In the design GUI, the Placeholder Properties are not available through the right-click menu for the textbox. You need to click twice inside a textbox (i.e., activate your cursor within the textbox) and then right-click to see this menu item.

    If there's nothing in the textbox yet: you'll see Create Placeholder in the menu.
    SplitFormatting_CreatePlaceholder

    If you highlight a field: you'll see Placeholder Properties in the menu.
    SplitFormatting_PlaceholderProperties

    If you highlight text: you'll see Text Properties in the menu.
    SplitFormatting_TextProperties

    The Placeholder Properties pane offers different tooltip, formatting, and action for the text selected in the textbox. The Text Properties pane offers the same options, with one exception: it doesn't have the Number page of options since it's only formatting text.

    SplitFormatting_PlaceholderPropertiesPane

    Use the various options to specify formatting desired for the selected portion of the textbox. You may use several combinations of Placeholder Properties and Text Properties within one single textbox. Valentino Vranken has a very nice discussion on his blog entry: The Power of the Placeholder.

    HTML Tags
    This option delivers a bit more flexibility, particularly if you have a complex expression in your textbox. Using HTML tags will work if you have a complex expression (i.e., <Expr> shown in the design view).

    First, you do need to define Placeholder Properties on the Expression:

    SplitFormatting_PlaceholderPropertiesForExpr

    Within the Placeholder Properties, change the default Markup type to be "HTML – Interpret HTML tags as styles." If you forget to change this radio button, then the html tags will be rendered as literal text.

    SplitFormatting_PlaceholderPropertiesHTMLRadioBtn

    Then within your expression, insert the HTML tags as needed.

    SplitFormatting_HTMLInExpression

    Only a subset of HTML tags are supported within SSRS, such as bold, italics, and underline. The MSDN page on Formatting Text and Importing HTML specifies the valid HTML tags you may use within an SSRS textbox. If you use an HTML tag that isn't supported in SSRS, it will be ignored.

    As a sidenote, using HTML tags within a simple expression will work as well:

    SplitFormatting_HTMLInPlaceholder

    However, in a real situation, I would reserve using HTML tags to situations when I have a complex expression. With a simple expression, I'd opt to keep the formatting options simpler.

    A Word About <Expr>
    Above I stated a couple of times that you can't have just <Expr> for the entire textbox and have the placeholder technique work, except for the HTML tags method. However, an <Expr> inside part of the textbox will still work.

  • #766054
    You can use " Selected Text" Properties. You directly make the text bold. It is easy way to make the text bold
    In "Placeholder Properties" also you can do this. "HTML Tags" that is another way to do this.

    By Nathan
    Direction is important than speed


Sign In to post your comments