Blog Home  Home RSS 2.0 Atom 1.0 CDF  
Ruminations of a Developer - Reporting with HTML. Who Needs Expensive Reporting Tools
Mark Bonafe
 
 Monday, February 20, 2006

Printing a web page that represents a report has been difficult for me in the past.  I want to print a header and/or a footer that repeats on every printed page.  The screen version certainly isn't paginated, so how can you print a good looking report?  Style (or CSS) to the rescue. 

Put the following Style tag, or something similar, in the header of the page.

<STYLE TYPE=”text/cssMEDIA=”screen, print>
<!--
TABLE {
  table-layout: fixed;
  border: 0;
  cellspacing: 1;
  cellpadding: 1;
  font-family: Arial;
  font-size: 8pt;
  }
TH {
  font-family: Arial;
  color: black;
  background-color: lightgrey;
  text-decoration: underline;
  }
THEAD {
  display: table-header-group;
  }
TFOOT {
  display: table-footer-group;
  }
-->
</STYLE>

Since nearly every report uses an HTML Table, this works very well.  The THEAD and TFOOT styles is what makes the table a report.  If you don't want to setup a style tag, you can enter the style right into the table.

<table style="table-layout:fixed">
    <colgroup>
        <col width="150"/>
        <col width="100"/>
        <col width="150"/>
    </colgroup>
    <thead style="display:table-header-group">
        <tr>
            <td>Header column 1</td>
            <td>Header column 2</td>
            <td>Header column 3</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Body column 1</td>
            <td>Body column 2</td>
            <td>Body column 3</td>
        </tr>
    </tbody>
    <tfoot style="display:table-footer-group">
        <tr>
            <td>Footer column 1</td>
            <td>Footer column 2</td>
            <td>Footer column 3</td>
        </tr>
    </tfoot>
</table>
 
Sounds too easy to be true but it works very nicely.  Of course, adding more style (bolding, underlining, background and foreground colors, etc.) makes this a very nice reporting option.

***Originally posted on DotNetJunkies on February 16, 2005

2/20/2006 2:08:19 PM (Eastern Standard Time, UTC-05:00)  #    Comments [8]    |  Trackback
7/19/2006 6:28:00 AM (Eastern Standard Time, UTC-05:00)
thanks, this code helped
4/10/2011 8:43:28 PM (Eastern Standard Time, UTC-05:00)
5fOCPd IJWTS wow! Why can't I think of things like that?
4/23/2011 10:45:27 PM (Eastern Standard Time, UTC-05:00)
jD2mm2 , [url=http://exowavrztdxs.com/]exowavrztdxs[/url], [link=http://mzalhafcflvk.com/]mzalhafcflvk[/link], http://ufcayvwdrxfl.com/
4/25/2011 6:13:51 PM (Eastern Standard Time, UTC-05:00)
Levitra 316 levitra viagra online %[
4/27/2011 7:15:28 AM (Eastern Standard Time, UTC-05:00)
car insurance =O online auto insurance 729950
4/29/2011 7:12:39 AM (Eastern Standard Time, UTC-05:00)
Tramadol >:-P Ultram :(((
5/5/2011 8:14:02 AM (Eastern Standard Time, UTC-05:00)
Viagra wuxsd levitra and grapefruit juice 189
5/6/2011 12:13:25 AM (Eastern Standard Time, UTC-05:00)
online slots ilg cheap flights >:-(( air tickets cnvc
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Copyright © 2012 Mark Bonafe. All rights reserved.