I do many of the reports on the intranets I work on. Building reports
with ASP is incredibly easy. build a couple decent subroutines for the
table building, maybe go grab my DBConn.asp file from coolpier.com to
simplify the database stuff.
Data is some custom for a business, ASP reports will probably be
easier than using an program anyway.
This is a subroutine I would use ... I haven't tested yet ...
<%
'// The cp_CellWidths and cp_CellTitles need to be seperated by @@@
'// It's been easier to have a string in my code, and let sub
make the arrays for the above.
'// For a blank title box in your string put
'// For no titles simply put an empty string "" which will
make the array cp_CellTitlesArray = -1
'//I occasionally modify this script ... without titles, this that
whatever
'// KNOWING my table is going to be 4 columns ... I have done
the follwing
'// When I modify it, I just copy the subroutine and paste it
below named cp_BuildTable2
'// My cp_BuildTable2 here is an example of how to use CSS
classes for different columns
'// My cp_BuildTable3 is a simple example with every other row
a different CSS class
'// Where there are changes I put '// **********
'// In fact, I am going to add cp_CellClasses before I put
this script on my site
'// As always, the cp_ coolpier.com prefix is used before all variable
names as to not conflict with any you may be using.
'// As always, use this script at your own risk ... I do not guarantee
the effects of this script.
Sub cp_BuildTable(cp_DataArray, cp_CellWidths, cp_CellTitles)
Dim cp_tableHTML, cp_rowHTML
cp_tableHTML = "<table align=""center"" valign=""top""
width=""96%"">"
cp_rowHTML = "<tr>"
Dim cp_CellWidthsArray, cp_CellTitlesArray '//cell HTML left
in loop for easy modifying later
cp_CellWidthsArray = Split(cp_CellWidths, "@@@")
cp_CellTitlesArray = Split(cp_CellTitles, "@@@")
Dim cp_n, cp_i, cp_Rows, cp_Columns: cp_Rows =
ubound(cp_DataArray,2): cp_Columns = ubound(cp_DataArray,1)
With Response
.Write cp_tableHTML
'// TITLES
If Not cp_CellTitlesArray = -1 Then
.Write cp_rowHTML
For cp_n = 0 to cp_Columns
.Write "<td align=""center"" valign=""middle""
class=""yourTitleCSSclass"" width=""" & cp_CellWidthsArray(cp_i) &
""">"
.Write cp_CellTitlesArray(cp_n)
.Write "</td>"
Next
.Write "</tr>"
End If
'// DATA
For cp_n = 0 to cp_Rows
.Write cp_rowHTML
For cp_i = 0 to cp_Columns
.Write "<td align=""left"" valign=""top""
class=""yourCSSclass"" width=""" & cp_CellWidthsArray(cp_i) & """>"
.Write cp_DataArray(cp_i, cp_n)
.Write "</td>"
Next
.Write "</tr>"
Next
.Write "</table>"
End With
End Sub
Sub cp_BuildTable2(cp_DataArray, cp_CellWidths, cp_CellTitles)
Dim cp_tableHTML, cp_rowHTML, cp_ClassesArray(3)'// **********
cp_tableHTML = "<table align=""center"" valign=""top""
width=""96%"">"
cp_rowHTML = "<tr>"
cp_ClassesArray(0) = "myclass1"'// **********
cp_ClassesArray(1) = "myclass2"'// **********
cp_ClassesArray(2) = "myclass3"'// **********
cp_ClassesArray(3) = "myclass4"'// **********
Dim cp_CellWidthsArray, cp_CellTitlesArray '//cell HTML left
in loop for easy modifying later
cp_CellWidthsArray = Split(cp_CellWidths, "@@@")
cp_CellTitlesArray = Split(cp_CellTitles, "@@@")
Dim cp_n, cp_i, cp_Rows, cp_Columns: cp_Rows =
ubound(cp_DataArray,2): cp_Columns = ubound(cp_DataArray,1)
With Response
.Write cp_tableHTML
'// TITLES
If Not cp_CellTitlesArray = -1 Then
.Write cp_rowHTML
For cp_i = 0 to cp_Columns
.Write "<td align=""center"" valign=""middle""
class=""" & cp_ClassesArray(cp_i) & """ width=""" &
cp_CellWidthsArray(cp_i) & """>" '// **********
.Write cp_CellTitlesArray(cp_i)
.Write "</td>"
Next
.Write "</tr>"
End If
'// DATA
For cp_n = 0 to cp_Rows
.Write cp_rowHTML
For cp_i = 0 to cp_Columns
.Write "<td align=""left"" valign=""top""
class=""" & cp_ClassesArray(cp_i) & """ width=""" &
cp_CellWidthsArray(cp_i) & """>"
.Write cp_DataArray(cp_i, cp_n)
.Write "</td>"
Next
.Write "</tr>"
Next
.Write "</table>"
End With
End Sub
Sub cp_BuildTable3(cp_DataArray, cp_CellWidths, cp_CellTitles)
Dim cp_tableHTML, cp_rowHTML, cp_ClassesArray(1), cp_RowClass
'// **********
cp_tableHTML = "<table align=""center"" valign=""top""
width=""96%"">"
cp_rowHTML = "<tr>"
cp_ClassesArray(0) = "firstColumnsClass" '//
**********
cp_ClassesArray(1) = "secondColumsClass" '//
**********
Dim cp_CellWidthsArray, cp_CellTitlesArray '//cell HTML left
in loop for easy modifying later
cp_CellWidthsArray = Split(cp_CellWidths, "@@@")
cp_CellTitlesArray = Split(cp_CellTitles, "@@@")
Dim cp_n, cp_i, cp_Rows, cp_Columns: cp_Rows =
ubound(cp_DataArray,2): cp_Columns = ubound(cp_DataArray,1)
With Response
.Write cp_tableHTML
'// TITLES
If Not cp_CellTitlesArray = -1 Then
For cp_n = 0 to cp_Columns
.Write "<td align=""center"" valign=""middle""
class=""yourTitleCSSclass"" width=""" & cp_CellWidthsArray(cp_i) &
""">"
.Write cp_CellTitlesArray(cp_n)
.Write "</td>"
Next
.Write "</tr>"
End If
'// DATA
cp_RowClass = cp_ClassesArray(1) '//**********
For cp_n = 0 to cp_Rows
If cp_RowClass = cp_ClassesArray(1) Then: cp_RowClass
= cp_ClassesArray(0): Else: cp_RowClass = cp_ClassesArray(1): End If
'//**********
.Write "<tr class=""" & cp_RowClass & """>"
'//**********
.Write cp_rowHTML
For cp_i = 0 to cp_Columns
.Write "<td align=""left"" valign=""top""
class=""yourCSSclass"" width=""" & cp_CellWidthsArray(cp_i) & """>"
.Write cp_DataArray(cp_i, cp_n)
.Write "</td>"
Next
.Write "</tr>"
Next
.Write "</table>"
End With
End Sub
%>
Anyway, I think it is pretty easy to make nice looking reports with a
few custom subroutines. Anyway, have fun coding.
Brynn
www.coolpier.com
P.S. I also sometimes modify the scripts to build the html for the
reports into an array ... then use that array with my ArrayToText.asp
script and build static reports. For reports that are going to be
generated like every morning or something ... you can also use vbs
scripts to execute your .asp files to build these reports on a timer.
I make write the html files so that they are reading a static page,
and the database isn't being hit for every report view ... AND the
time and resources to dynamically build the report isn't there ... AND
it is nice to have an archive of all the reports ever written.
You can use my little FilesInFolder.asp script to read the file names
in the folder with all the reports in it ... or what I like to do is
enter each file name into a text file as they are being written ... I
use my ArrayToText_Append.asp for that.
ANYWAY, just thought I would post :)
Brynn
www.coolpier.com
On Sat, 20 Dec 2003 21:36:00 GMT, "Jeff Boyer" <je**@jdboyer.com>
wrote:
So your both saying my only option is to run some queries and dynamically
build the tables to display the results?
Jeff
"Michael D. Kersey" <md******@hal-pc.org> wrote in message
news:eP**************@TK2MSFTNGP10.phx.gbl... Jeff Boyer wrote: > Ok, I hear what your saying but for large reports that total columnsisn't > that allot of code to write? I was hoping I didn't have to re-invent the
> wheel. I thought maybe there might be some sort of plugin to use with
> Interdev or maybe a third party application I could call from my page.
> Jeff
You can
1. fetch the SQL result set into a recordset and then accumulate totals
on the ASP page by looping through the result set, or
2. issue a separate SQL query for the required summary columns.
FWIW you can fetch as many result sets (issue as many SQL statements) as
you wish on a single ASP page.
Good Luck,
Michael D. Kersey