printing a long HTML table

L

Larry

I have a CGI program that generates a fairly long HTML table in
response to a query. How do I make it so that the user can print the
table from their browser and have the column headings show up on the
top of each page? I know about the "page-break-after" style tag, but I
have no way to know when to output it. Another option I've considered
is something like Crystal Reports, but that's expensive, complex, and
way more than what I need.
 
M

mbstevens

Larry said:
I have a CGI program that generates a fairly long HTML table in
response to a query. How do I make it so that the user can print the
table from their browser and have the column headings show up on the
top of each page? I know about the "page-break-after" style tag, but I
have no way to know when to output it. Another option I've considered
is something like Crystal Reports, but that's expensive, complex, and
way more than what I need.

Since you are generating the pages with a programming language,
couldn't you come up with some kind of heuristic test?

if (position >= MAXROW)
generate break
if ((row contains x) and (position >= MINROW)
generate break
if ...
if ...
if ....

Should be easy enough to do in most CGI scripting languages.
 
O

Oli Filth

mbstevens said the following on 14/09/2005 16:15:
Since you are generating the pages with a programming language, couldn't
you come up with some kind of heuristic test?

if (position >= MAXROW)
generate break
if ((row contains x) and (position >= MINROW)
generate break
if ...
if ...
if ....

Should be easy enough to do in most CGI scripting languages.

But that can't take account of page size, print margins, browser text
size, ...
 
D

Dima Gofman

Simple! In FireFox it's enough to simply use <thead> and <th> tags and
to get the same effect in IE all you need is a bit of CSS. Like so:

<html><head><title></title>
<style type='text/css'>
thead{display:table-header-group}
</style>
</head><body>
<table>
<thead>
<tr>
<th>col1</th>
<th>col2</th>
<th>col3</th>
<th>col4</th>
<th>col5</th>
</tr>
</thead>
<tbody>
<tr>
<td>x1</td>
<td>x2</td>
<td>x3</td>
<td>x4</td>
<td>x5</td>
</tr>
..........alot of rows...........
</tbody>
</table></body></html>


-
Dima Gofman
 
M

mbstevens

Oli said:
mbstevens said the following on 14/09/2005 16:15:



But that can't take account of page size, print margins, browser text
size, ...


Browser text size need not affect the printout.
For page size and print margins, you would could
1) give the visitor a choice of several common formats available
in different parts of the world;
2) let the visitor fill out a form describing her page size,
then set MAXROW, MINROW, margins, styles, etc. from that;
 
?

=?ISO-8859-1?Q?G=E9rard_Talbot?=

Larry a écrit :
I have a CGI program that generates a fairly long HTML table in
response to a query. How do I make it so that the user can print the
table from their browser and have the column headings show up on the
top of each page? I know about the "page-break-after" style tag, but I
have no way to know when to output it. Another option I've considered
is something like Crystal Reports, but that's expensive, complex, and
way more than what I need.

Use <thead> accordingly.
"When long tables are printed, the table head and foot information may
be repeated on each page that contains table data."
http://www.w3.org/TR/html401/struct/tables.html#h-11.2.3

http://www.w3.org/WAI/UA/TS/html401/cp1001/1001-THEAD-TBODY-TFOOT-OVERFLOW.html

Gérard
 
?

=?ISO-8859-1?Q?G=E9rard_Talbot?=

Dima Gofman a écrit :
Simple! In FireFox it's enough to simply use <thead> and <th> tags and
to get the same effect in IE all you need is a bit of CSS. Like so:

<html><head><title></title>
<style type='text/css'>
thead{display:table-header-group}

thead by default is declared as display: table-header-group in CSS 2.x
compliant browsers. So there is really no need to redefine it again. In
other browsers, like MSIE 6, declaring thead{display:table-header-group}
won't achieve anything anyway since display:table-header-group is not
supported.

Gérard
 
L

Larry

Dima said:
Simple! In FireFox it's enough to simply use <thead> and <th> tags and
to get the same effect in IE all you need is a bit of CSS. Like so:

<html><head><title></title>
<style type='text/css'>
thead{display:table-header-group}
</style>
</head><body>

....

Thanks! I'll try that!
 
D

Dima Gofman

Gérard Talbot said:
declaring thead{display:table-header-group}
won't achieve anything anyway since display:table-header-group is not
supported.

It is in MSIE6, IE6 doesn't display <thead> at the top of every page by
default, thead{display:table-header-group} forces it to do this and it
doesn't hurt firefox. Try it out. Unfortunately i don't have Opera
handy to see what works/doesn't work there

-
Dima Gofman
 
L

Leif K-Brooks

Gérard Talbot said:
thead by default is declared as display: table-header-group in CSS 2.x
compliant browsers.

CSS does not require any particular default rendering of HTML elements.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top