{"id":190,"date":"2007-08-10T13:53:00","date_gmt":"2007-08-10T13:53:00","guid":{"rendered":"\/lisa\/post\/2007\/08\/10\/Snips-and-snails-and-puppy-dog-tails-what-little-polygons-are-made-of.aspx"},"modified":"2007-08-10T13:53:00","modified_gmt":"2007-08-10T13:53:00","slug":"snips-and-snails-and-puppy-dog-tails-what-little-polygons-are-made-of","status":"publish","type":"post","link":"https:\/\/spacefold.com\/lisa\/2007\/08\/10\/snips-and-snails-and-puppy-dog-tails-what-little-polygons-are-made-of\/","title":{"rendered":"Snips and snails and puppy dog tails: what little polygons are made of"},"content":{"rendered":"<p>When I wrote about the <a title=\"Reporting Convergences Part One in Many\" href=\"\/lisa\/2007\/08\/01\/Reporting-Convergences-Part-One-in-Many\/\">genesis of&nbsp;XMLRSDocs-RDLDocumenter<\/a>&nbsp;I credited <a title=\"Jazz Up Your Data Using Custom Report Items In SQL Server Reporting Services\" href=\"http:\/\/msdn.microsoft.com\/msdnmag\/issues\/06\/10\/SQLServer2005\/default\/\">Teo Lachev&#8217;s MSDN article<\/a>&nbsp;and its ProgressBarCRI sample as a source of inspiration and code samples for the development of Custom Report Items.&nbsp;<\/p>\n<p>I neglected to credit <a title=\"Chris Hays's Reporting Services Sleazy Hacks Weblog: Custom Report Items\" href=\"http:\/\/blogs.msdn.com\/chrishays\/archive\/2005\/10\/04\/CustomReportItemSample\/\">Chris Hays, whose PolygonCRI Sample<\/a> stands behind both Teo&#8217;s Custom Report Item code and mine. I am happy to say that updates to the SQL Server sample set and&nbsp;the on-line documentation have given Chris&#8217; code the pride of place that it deserves.<\/p>\n<p>In my downloaded copy of the samples,&nbsp;<strong>PolygonsCustomReportItem<\/strong> shows up in the <strong>C:\\Program Files\\Microsoft SQL Server\\90\\Samples\\Reporting Services\\Extension Samples<\/strong> location, although I couldn&#8217;t tell you exactly what download I picked to get it.&nbsp; You&#8217;ll probably find the download instructions buried in the <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ms345265\/\">Custom Report Item Sample doc topic<\/a>, which points to this solution. I&#8217;m just skimming this topic now because, frankly, the light gets all bendy-like when I try to read certain portions of the docs, and this is one of them.<\/p>\n<p>In each of the three versions, even though we&#8217;re each rendering different types of custom content,&nbsp;you&#8217;re going to find a remarkably similar custom rendering approach:<\/p>\n<ul>\n<li>You render to an image, using pretty standard Graphics methods.<\/li>\n<li>\n<div>You create an&nbsp;object of Microsoft.ReportingServices.ReportRendering.Image type and you copy what you rendered to that image.&nbsp; This operation&nbsp;is done with&nbsp;MemoryStream in all three versions of the code &#8212; I have no idea whether it&#8217;s required or whether Teo just did it that way because Chris did, so I did it too &lt;g&gt; .<\/div>\n<\/li>\n<li>\n<div>You provide this&nbsp;object of Microsoft.ReportingServices.ReportRendering.Image type to the standard rendering process as the item-to-be-rendered, when the engine requests it.<\/div>\n<\/li>\n<\/ul>\n<blockquote>\n<h5>My point, and I do have many of them<br \/>(said the little polygon)&#8230;<\/h5>\n<\/blockquote>\n<p>I&#8217;m writing about this because in the past week I&nbsp;have answered a question about &#8220;rich text formatting&#8221; in Reporting Services a bunch of times.&nbsp; Say you have some content stored in a database with RTF markup or HTML markup.&nbsp; Right now, if you want to use the out-of-the-box RS output rather than writing something to render the whole report yourself, your best option is to create a Custom Report Item. Your code can reads your markup in the data, along with&nbsp;other attributes of the control (such as size and font)&nbsp;and then render&nbsp;the content&nbsp;to an image, however you think it should appear.&nbsp;<\/p>\n<p>Not a wonderful option, considering that it won&#8217;t be searchable text, but do-able. In each answer, for what it&#8217;s worth, I&#8217;ve also pointed folks to <a title=\"Katmai post on rich text formatting\" href=\"http:\/\/forums.microsoft.com\/MSDN\/ShowPost.aspx?PostID=1827171&amp;SiteID=1\">a post on the Katmai RS forum<\/a>&nbsp; &#8212; which indicates that happier days may be ahead for those of you in this predicament.&nbsp; You&#8217;ll also find that <a title=\"Katmai post on charting\" href=\"http:\/\/forums.microsoft.com\/TechNet\/ShowPost.aspx?PostID=1786951&amp;SiteID=17\">your charting options will improve in Katmai<\/a>.&nbsp; Charts have been another big reason to use Custom Report Items in RS.<\/p>\n<p>Still, sometimes nothing beats the low-level approach, and it will be worth your while to understand how to custom-render when the occasion arises, even in Katmai and beyond.<\/p>\n<p>If you&#8217;re reading this and scratching your head about how these little gimmicky Custom Report Items connect with your data, realize that you&#8217;ve got access to the CustomReportItem&#8217;s CustomProperties collection at the time you&#8217;re doing this. (The CustomReportItem&#8217;s CustomProperties collection is a bit different from the CustomProperties collections of other report elements &#8212; and oh how I wish this were not the case &#8212; but that&#8217;s another post.)&nbsp;<\/p>\n<p>Take a look at one of Teo&#8217;s sample reports.&nbsp; You will easily see that custom properties can be data bound &#8212; I&#8217;ll put a truncated version of the XML definition of the ProgressTracker custom item here:&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomReportItem Name=&#8221;progressTracker1&#8243;&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Type&gt;ProgressTracker&lt;\/Type&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Style&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: green;\">&lt;!&#8211; style attributes here &#8211;&gt;<\/span> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/Style&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomProperties&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomProperty&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Name&gt;Value&lt;\/Name&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Value&gt;<span style=\"color: red;\">=Fields!Product_Gross_Profit_Margin_Status_.Value<\/span>&lt;\/Value&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/CustomProperty&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomProperty&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Name&gt;OutlineColor&lt;\/Name&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Value&gt;Gray&lt;\/Value&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/CustomProperty&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: green;\">&lt;!&#8211; more custom properties here &#8211;&gt; <br \/><\/span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/CustomProperties&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/CustomReportItem&gt;<\/p>\n<p>How far does&nbsp;this capability&nbsp;go?&nbsp; As far as you need it to. Looking at Chris&#8217;s custom report item&#8217;s attributes, PolygonsCRI has a pretty cozy relationship with a dataset:<\/p>\n<p>&lt;CustomProperties&gt;<br \/>&lt;CustomProperty&gt;<br \/>&nbsp;&nbsp; &lt;Name&gt;poly:MaxX&lt;\/Name&gt;<br \/>&nbsp;&nbsp; &lt;Value&gt;<span style=\"color: red;\">=Max(Fields!X.Value,&#8221;DataSet2&#8243;)+<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; iif(Min(Fields!X.Value,&#8221;DataSet2&#8243;)&gt;0, Min(Fields!X.Value,&#8221;DataSet2&#8243;),0)<br \/>&nbsp; <\/span>&lt;\/Value&gt;<br \/>&lt;\/CustomProperty&gt;<br \/>&lt;CustomProperty&gt;<br \/>&nbsp;&nbsp; &lt;Name&gt;poly:MinX&lt;\/Name&gt;<br \/>&nbsp;&nbsp; &lt;Value&gt;<span style=\"color: red;\">=iif(Min(Fields!X.Value,&#8221;DataSet2&#8243;)&gt;0,0,<br \/>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Min(Fields!X.Value,&#8221;DataSet2&#8243;))<br \/>&nbsp; <\/span>&lt;\/Value&gt;<br \/>&lt;\/CustomProperty&gt;<br \/>&nbsp;&nbsp; <span style=\"color: green;\">&lt;!&#8211; and so on, lots more here &#8211;&gt;<br \/><\/span>&lt;\/CustomProperties&gt;<\/p>\n<p>If you look at one of <a title=\"XMLRDLDocs-RDLDocumenter Article\" href=\"\/articles\/xmlrsdocs\/\">RDLDocumenterDesigner<\/a>&#8216;s sets of attributes, on the other hand, you will see nothing of the sort. <strong>My<\/strong> little custom report item doesn&#8217;t bind to data at all, because it has a completely different raison d&#8217;&ecirc;tre.&nbsp;While it knows how to render itself at runtime, it&#8217;s a design-time utility at heart. Just goes to show what a versatile puppy the Custom Report Item really is.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When I wrote about the genesis of&nbsp;XMLRSDocs-RDLDocumenter&nbsp;I credited Teo Lachev&#8217;s MSDN article&nbsp;and its ProgressBarCRI sample as a source of inspiration and code samples for the development of Custom Report Items.&nbsp; I neglected to credit Chris Hays, whose PolygonCRI Sample stands behind both Teo&#8217;s Custom Report Item code and mine. I am happy to say that<a class=\"more-link\" href=\"https:\/\/spacefold.com\/lisa\/2007\/08\/10\/snips-and-snails-and-puppy-dog-tails-what-little-polygons-are-made-of\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,6,11],"tags":[],"class_list":["post-190","post","type-post","status-publish","format-standard","hentry","category-reporting","category-sql-server","category-xmlrsdocs"],"_links":{"self":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts\/190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/comments?post=190"}],"version-history":[{"count":0,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts\/190\/revisions"}],"wp:attachment":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/media?parent=190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/categories?post=190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/tags?post=190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}