SQL Server Showing HTML formated content in a SSRS report

nr9pn0ug  于 2023-02-18  发布在  其他
关注(0)|答案(1)|浏览(105)

We have a requirement to develop few reports using SSRS for a existing web application developed by set of previous developers. So that without touching the application code we are going to develop a reporting solution using SSRS since the back end of the application is already MS SQL Server.

While developing reports we have come across a problem because of a practice followed by the original developers. This is basically a online examination portal and the developers have stored questions in the database with HTML formatting such as , tags, style sheet formatting and so on. Now when we display these Questions in SSRS web report (in a table) it is unreadable because of these tags.

So that I tried to use a separate functions to get rid of from these tags and to filter out actual problem. This was not successful as we are losing full structure (bullets, numbers, line breaks etc.) of the question together with all diagrams referred by tags.

In SSRS is there a way to develop a web page like report which is capable of displaying this html formatted content or to display the content inside table cells, formatted according to respective html formatting? Otherwise we may have to put big effort to develop html reports manually.

Can anybody please provide your feedback/ solution.

Thank you.

Following is a sample data extracted from the database. You may use a real time html viewer to view the actual question inside the HTML ( http://htmledit.squarefree.com )

You will be given a grid (<i>n&nbsp;</i>x&nbsp;<i>n, n </i>&gt;<i> </i>0), which has been divided on each unit <Br>
length both horizontally and vertically (see the image), and you have to print out how many perfect squares <Br> 
(can be any size) are there in the given grid. <i>n</i> is the side length of the grid.<div><br></div><div> Your program must read an integer (<i>n, 0 &lt; n &lt;= 100,000</i>)
<table class="MsoTableGrid" style="border-collapse:collapse;border:none;mso-border-alt:solid windowtext .5pt;
 mso-yfti-tbllook:1184;mso-padding-alt:0in 5.4pt 0in 5.4pt" border="1" cellpadding="0" cellspacing="0">
 <tbody><tr>
  <td style="width:27.9pt;border:solid windowtext 1.0pt;
  mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt" valign="top" width="37">
  <p class="MsoNormal" style="margin-bottom: 0.0001pt;">1</p>
  </td>
  <td style="width:31.5pt;border:solid windowtext 1.0pt;
  border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
  solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt" valign="top" width="42">
  <p class="MsoNormal" style="margin-bottom: 0.0001pt;">2</p>
  </td>
  <td style="width:27.0pt;border:solid windowtext 1.0pt;
  border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
  solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt" valign="top" width="36">
  <p class="MsoNormal" style="margin-bottom: 0.0001pt;">3</p>
  </td>
 </tr>
 <tr>
  <td style="width:27.9pt;border:solid windowtext 1.0pt;
  border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
  padding:0in 5.4pt 0in 5.4pt" valign="top" width="37">
  <p class="MsoNormal" style="margin-bottom: 0.0001pt;">4</p>
  </td>
  <td style="width:31.5pt;border-top:none;border-left:none;
  border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
  mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt" valign="top" width="42">
  <p class="MsoNormal" style="margin-bottom: 0.0001pt;">5</p>
  </td>
  <td style="width:27.0pt;border-top:none;border-left:none;
  border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
  mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt" valign="top" width="36">
  <p class="MsoNormal" style="margin-bottom: 0.0001pt;">6</p>
  </td>
 </tr>
 <tr>
  <td style="width:27.9pt;border:solid windowtext 1.0pt;
  border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
  padding:0in 5.4pt 0in 5.4pt" valign="top" width="37">
  <p class="MsoNormal" style="margin-bottom: 0.0001pt;">7</p>
  </td>
  <td style="width:31.5pt;border-top:none;border-left:none;
  border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
  mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt" valign="top" width="42">
  <p class="MsoNormal" style="margin-bottom: 0.0001pt;">8</p>
  </td>
  <td style="width:27.0pt;border-top:none;border-left:none;
  border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
  mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt" valign="top" width="36">
  <p class="MsoNormal" style="margin-bottom: 0.0001pt;">9</p>
  </td>
 </tr>
</tbody>
</table>
guicsvcw

guicsvcw1#

We can display HTML content in SSRS by selecting 'HTML-Interpret html tags as styles' present in placeholder properties.

But most of the styles present in your HTML code not supported by SSRS.

SSRS supports only few HTML tags and CSS styles. You can find them in this link.

https://learn.microsoft.com/en-us/sql/reporting-services/report-design/importing-html-into-a-report-report-builder-and-ssrs?view=sql-server-ver16

相关问题