Comparing HTML Reporting and MS SQL Server Reporting Services
page 1 of 2
Published: 23 Sep 2004
Unedited - Community Contributed
Abstract
I thought I had it made, using my own HTML reporting methods for Web applications and Crystal Reports for Windows applications, but a new tool is now of interest. With MS SQL Server Reporting Services I now have one solution for reports for Web and Windows forms applications.
by Terry Voss
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 22976/ 99

HTML Reporting

Before I worked almost exclusively on web forms, I worked quite a bit with Crystal Reports and found it clunky, but workable. When I tried to use it for web reporting, I found what I would expect to be about a page of HTML code would get about 20 pages of HTML generated. This led me to create my own HTML reports using one VB class called Html and 3 CSS classes called Report, Report1, and Invisible.

Here is the VB class:

 
Imports Microsoft.VisualBasic.ControlChars

Public Class Html

Public Shared BeginTablewBorder As String = 
"<table border=1 cellspacing=0 cellpadding=0 width=100% class=eval1>" & CrLf
Public Shared BeginTable As String = 
"<table border=0 cellspacing=0 width=100% class=Report1>" & CrLf
Public Shared BeginPBTable As String = 
"<table border=0 cellspacing=0 width=100% class=Report>" & CrLf
Public Shared BeginRow As String = "<tr>" & CrLf
Public Shared EndCell As String = "</font></td>" & CrLf
Public Shared endRow As String = "</tr>" & CrLf
Public Shared endTable As String = "</table>" & CrLf
Public Shared br As String = "<br>" & CrLf

Public Shared Function BeginCellTxt
(ByVal size As Integer, ByVal span As Integer) As String
Dim result As String
result = "<td colspan=" & span.ToString & 
"><font family=arial;sanserif; size=" & size.ToString & ">" & CrLf
Return result
End Function

Public Shared Function BeginCellNum(ByVal size As Integer) As String
Dim result As String
result = "<td width=33% align=right><font family=arial;sanserif; size=" 
& size.ToString & ">" & CrLf
Return result
End Function

End Class

Here are the CSS classes:
.report

{
page-break-before: always;
margin-left: 60px;
}
.report1
{
margin-left: 60px;
}
.invisible
{
visibility: hidden;
}

Causing pseudo-code lines, in the web form, like this representing one row of a table:

 
For Each trust As TrustEntity In trusts
reportHtml &= Html.BeginRow & Html.BeginCellTxt & _
trust.Name.Trim & Html.EndCell & Html.BeginCellTxt & _
bankNumber.Trim & Html.EndCell & Html.BeginCellNum & _
total.ToString("c") & Html.EndCell & Html.BeginCellNum & _
  totalHours.ToString() + Html.EndCell + Html.EndRow : line += 1
  reportHtml &= Me.CheckPageBreak(False)
Next

Private Function CheckPageBreak(ByVal force As Boolean) As String
  Dim reportHtml As String
  If line >= pageLines Or force Then
   reportHtml &= Html.EndTable
   reportHtml &= Html.BeginPBTable
   line = 1
   page += 1
  End If
  Return reportHtml
End Function

The CheckPageBreak method made page breaks so easy that it is hardly worth thinking about anymore, and if needed you could add input to handle whether a header displays. The above works well for a header, followed by a table of detail data. If one needs a highly formatted set of data just use Visual Studio on an aspx page to place the labels and text fields with a variable like ||name|| for each data position. Then save the HTML as a file and do a text replacement of ||name|| with your data after grabbing the HTML into a stream. Set a literal control's text to your enhanced HTML and you have a report that looks like it did in VS. With this method you can use all the looks and color that VS easily affords us. I mention this method because I haven't seen it mentioned before even though I'm sure many use it.

I was very happy with this manner of doing reports and had no complaints from clients except maybe when they wanted to get involved in report design and they didn't know HTML at all. Simple reports took about one hour and I felt totally in control of the looks. Never again would a report package keep me from getting exactly what the client wanted. Maybe my only concern was that I'm not that artistic, so if my clients didn't input something creative my reports looked fairly simple usually, but the HTML code for a simple one page view was one page of HTML not 20. It would take a very good alternative to make me switch from my current HTML methods. 
 


View Entire Article

User Comments

Title: Code for preview mode   
Name: Terry Voss
Date: 2007-04-26 5:27:01 PM
Comment:
For example in following report running url:
Response.Redirect("http://" & Utl.ComputerName & "/Reports/Pages/Report.aspx?ItemPath=%2fnwmrpts%2fpicklist0&rs:Command=Render&rc:toolbar=true")

Changing to: &rc:toolbar=false takes the toolbar with the mentioned controls on it. I haven't done more than that so don't know if there are any more customizations, but I'd guess yes.
Title: How to code to show preview mode on web   
Name: bp
Date: 2007-04-26 4:41:48 PM
Comment:
Can you elaborate:

"Reports can be controlled by code to show a preview mode with zoom, export, paging/start/end, find/next, or just show a nice colored page that prints well."

I have a big book on SSRS, as well as the help with SSRS itself, and they don't appear to cover how to do this for display on a web page.
Title: Difference   
Name: Sanket Shah
Date: 2006-06-21 1:43:49 AM
Comment:
Hi .
It's nice article.but can u provide me the more description on difference between crystal reports & reporting services and what are the prons & cons of the both ...

email id : sanketshah_18@yahoo.com

Thanks in advance.
Title: can u give me more info   
Name: vrunda
Date: 2005-12-10 5:52:26 AM
Comment:
hi its nice articale but m not cleared abt reporting services. i have read that i can edit report by editing RDl file of Report but after editing RDL file have i to do anything els for running existing report with changes
pls can u reply me on id vrunda@icenet.net






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-10-10 3:04:20 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search