1

I have a SQL Server 2008 R2 report where a field is actually text mixed with HTML. I changed the markup type in the placeholder to "HTML - Interpret HTML tags as styles" which renders the HTML. So far so good.

The field value in the database contains <p> tags, with no css classes or inline styling. From what I understand, the report builer replaces the field with a span containing the text and an embedding div. The paragraph tag itself seems to be replaced with the following inline value margin-top:10pt;padding-bottom:10pt; inside the div tag.

For example, if I have the following value in the field: <p>Test</p>, the html that is generated by the report builder is something like the following:

<div style="margin-top:10pt;padding-bottom:10pt;" class="Aaf7c1ec9914f4f479e0df1a72330c0f3106">
    <span class="Aaf7c1ec9914f4f479e0df1a72330c0f3105">Test</span>
</div>

If I remove the paragraph tags in the field so I have just the word Test, I get the following HTML:

<div class="Aaf7c1ec9914f4f479e0df1a72330c0f3106">
    <span class="Aaf7c1ec9914f4f479e0df1a72330c0f3105">Test</span>
</div>

I would like to change the inline style value that is added to margin-top:0pt;padding-bottom:0pt; but I don't know where the report builder gets the default values.

I've searched in the various css files on the report server but they seem to relate to the report manager and toolbars, not the actual report.

Where /how can I change the css values for default paragraph style?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Randi
  • 33
  • 3

2 Answers2

0

@Randi you can replace the default inline CSS value generated by SQL Server using !important. This will overwrite the inline CSS property.

keep database field value in <p> tag so you will get some inline css properties.

Here is this working example I use a background-color:gold as inline. and in css I've change the background color using !important.

div{background:red !important;}
<div style="margin-top:10pt;padding-bottom:10pt; background:gold;" class="Aaf7c1ec9914f4f479e0df1a72330c0f3106">
    <span class="Aaf7c1ec9914f4f479e0df1a72330c0f3105">Test</span>
</div>
Kheema Pandey
  • 9,977
  • 4
  • 25
  • 26
  • From what I can gather, you cannot import custom css in the report itself. When I try to get answers freom the web to add custom css to a report, they answers seem to apply for the report toolbar and manager only (For example: http://stackoverflow.com/questions/4033208/how-to-apply-customized-css-to-ssrs-report ). That is why I asked where the report builder stores those default values so I can replace them. – Randi May 15 '15 at 15:43
  • aah i see..only solution is to find the code how the inline css value applied to any element.. – Kheema Pandey May 15 '15 at 15:47
  • so reports comes in HTML format? can't we add javascript ? – Kheema Pandey May 15 '15 at 15:53
  • 1
    Adding custom css this way won't change anything vacause it states "Modifying style sheets has no effect on the appearance of published reports that you run on a report server. In Reporting Services, reports do not reference style sheets. Ad hoc reports that are auto-generated by the report server use style information that is stored as an embedded resource in the report server program files. Reports that you create in Report Designer use the fonts, colors, and layout that you specify in the report definition. Styles are created inline with the rest of the layout." – Randi May 15 '15 at 16:05
  • I appreciate your help though! :) – Randi May 15 '15 at 16:05
  • I wish I could help you. But I no nothing about sql server. – Kheema Pandey May 15 '15 at 16:11
0

I had the same problem and did not find a way to set these styles. I ended up using a workaround. I replaced the p-Tags with div-Tags, because apparently those don't get padding and margin:

Select the text box -> rightclick -> placeholder properties -> value (this is where the field you render should be entered) -> enter =Replace(Replace(Fields!<name of your field>.Value, "<p>", "<div>"), "</p>", "</div>"))

This of course only works if you are sure all your p-Tags are exactly of the form <p>. If there is more variance / other tags you want to replace, you could add more replace-statements.

dummdidumm
  • 4,828
  • 15
  • 26