THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | |
in Search

The Bit Bucket (Greg Low): IDisposable

Ramblings of Greg Low (SQL Server MVP, MCM and Microsoft RD) - SQL Down Under

Rendering HTML in Reporting Services Text Boxes in SQL Server 2008

Some time back, I posted about how to do this. Well by the time we got to RTM, this had changed.

There isn't a "create placeholder" option when you right-click a cell any more.

When you drag a field into a cell, it creates a placeholder that contains the field. If you right-click the placeholder that was added, you'll see an option to edit the Placeholder Properties. What threw me for a while was that if you right-click the cell, you won't see this option. Turns out you have to right-click the field-name within the cell, not the blank area beside the name within the cell. Thanks to my colleague Jessica Moss for helping me find it.

This really isn't very good UI work in the report designer. It's quite counter-intuitive and different to how cell selection, etc. works in other products like Excel.

Published Friday, December 19, 2008 5:12 PM by Greg Low

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

john said:

I am having the same problem that is one of my fields in the report is outputing html I was wondering if there is any way you can do the same in SQL Reporting 2005?

July 9, 2009 2:04 PM
 

Linda said:

I have the same question as John. How can this be done in SSRS 2005?

November 2, 2009 1:53 PM
 

Ron said:

Yep, me too! SSRS for 2005?

February 26, 2010 2:59 PM
 

Ahmet said:

@john, Linda, Ron: You can not achive with default properties/functionalities of SSRS 2005.

You can write a custom code in vb that interpret html into text.(Report Properties --> Code).

That's all you can do in SSRS 2005. Good luck.

March 2, 2010 4:56 AM
 

Candi said:

I am trying to do this in 2008 with the italics, but it only prints the tags in plain text.  I have it marked for HTML in the placeholder.  Is there something I am missing?

June 21, 2010 7:36 PM
 

Brigitte said:

Thank you, thank you, thank you!! :)

July 29, 2010 11:23 AM
 

Jack said:

Man, this kept me from progressing for at least 3 or 4 hours. What an obscurely integrated feature. Thanks for the tip.

February 1, 2011 5:51 PM
 

Vince said:

Thanks a lot ;)

July 8, 2011 10:45 AM
 

Shanon said:

Thanks for the tip! Hope they just make this a property you can easily access in Crescent...

October 18, 2011 12:04 PM
 

Andrew said:

Wow... this really is not intuitive.   Clicked «Expr», right clicked 'placeholder' and set to HTML.

March 28, 2012 1:11 PM
 

Yaroslav Rutsky said:

Alternative method to display HTML fields in reports

If you have reduced set of HTML tags in your dataset fields (like tables, formatting, inline tags), you can try JS-injection.

It is used to convert an HTML-encoded field, that’s generated by Report Manager into actual tags after page is loaded, but before rendered.

Injection use Ajax Client Life-Cycle Events (http://msdn.microsoft.com/en-us/library/bb386417.aspx).

You need to modify script Install Dir\Reporting Services\ReportManager\js\ReportingServices.js by add this function at the beginning:

///////////////////////////////////////////////////////////

//SSRS 2008 R2 HTML tags injection before render report

/////////////////////////////////////////////////////////////

function pageLoad() {

var toDecode = document.getElementsByTagName("div");

for (var i = 0; i < toDecode.length; ++i){

    if(toDecode[i].innerHTML.indexOf("&lt;table ") == 0){

        //alert(toDecode[i].innerText);

        Decoded = toDecode[i].innerText || toDecode[i].textContent; //IE, Opera vs FF

        toDecode[i].innerHTML = Decoded;

    }

}

}

///////////////////////////////////////////////////////////

//End injection

///////////////////////////////////////////////////////////

Code gets all DIV elements in loaded page

Check for each DIV if encoded tags ("&;;lt;table" in this case) is present at position=0

Swap innerText to innerHTML property and then render page

You can modify step 2 to check for special tag, if you sure, that it is always at position=0 in your field.

If tags with CSS classes or ids, you can modify this CSS: Install Dir\Reporting Services\ReportManager\Styles\ReportingServices.css

Also, you need to set placeholder property "General\Markup type" to "None - Plain text only" in all fields, that you want to convert.

Next possible modifications are:

If your fields have non-predefined structure, you can add prefix in placeholder value like this: ="HTMLInject:"+Fields!Field1.Value

And then modify injection script to seek at position=0 this prefix: if(toDecode[i].innerHTML.indexOf("HTMLInject:") == 0){

Also some code before swap to strip off this prefix.

Use alternative hidden columns to render HTML fields for other formats (DOC, EXCEL, etc). HINT: "Show or hide based on an expression" with "=Globals!RenderFormat.Name" and maybe Report's code functions to convert some tags into tags, that's supported by SSRS.

JS speed tuning on large pages

April 19, 2012 8:14 AM
 

Tony said:

Thank you!

February 27, 2013 5:13 AM
 

David C said:

You little beauty ...

Much appreciated ...

Just saved me a whole world of pain ...

0-0

 |

\-/

November 19, 2013 6:13 AM
 

Azita Guzzo said:

Thanks worked great

November 21, 2014 6:49 PM

Leave a Comment

(required) 
(required) 
Submit

This Blog

Syndication

Tags

No tags have been created or used yet.
Powered by Community Server (Commercial Edition), by Telligent Systems
  Privacy Statement