如此可以居中
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<script language="javascript">
function doPrint() {
var innerString;var result;
        inner = document.body.innerHTML;
        document.body.innerHTML = document.all.table1.innerHTML +document.all.dataContainer.innerHTML ;
        window.print();
        document.body.innerHTML = inner;
}
</script>
<SCRIPT>
var rowNum = 15;
var colNum = 4;
function drawTab (rows, cols, color, id)
{
sHTML = "<TABLE id='"+id+"' bgcolor='"+color+"' border=1 style='tableLayout:fixed'>";
sHTML += "\n<THEAD id='downTblHead'>\n";
i=0;
for (var j=0; j < cols; j++)
{
sHTML += "<TH id='a0"+j+"' nowrap style='word-wrap: break-word;'>这是: Row"+i+"Col"+j+"</TH>";
}
sHTML += "\n</THEAD>\n";
sHTML += "\n<TBODY>\n";
for (var i=1; i<rows; i++)
{
sHTML += "\n<TR>\n";

for (var j=0; j<cols; j++)
{
sHTML += "<TD id='a"+i+j+"' nowrap>这是: Row"+i+"Col"+j+"</TD>";
}
sHTML += "\n</TR>\n";
} sHTML += "\n</TBODY>\n";
sHTML += "\n</TABLE>";
return sHTML;

}function cloneHeader ()
{
var x = document.all['downTblHead'].cloneNode(true);
for (var j = 0; j < colNum; j++)
{
document.all['a0'+j].id = 'head'+j;
}
document.all['downTblHead'].id = "downTblHead4hidden";
document.all['upTbl'].appendChild(x);
document.all['upTbl'].width = document.all['downTblHead4hidden'].offsetWidth;
synchronizeHeader ()
}function synchronizeHeader ()
{
var ok = true;
var max = 0;
while (ok && max < 20)
{
max++;
ok = false;
for (var j = 0; j < colNum; j++)
{
if (document.all['a0'+j].offsetWidth != document.all['head'+j].offsetWidth)
{
ok = true;
document.all['a0'+j].style.width = document.all['head'+j].offsetWidth;
}
}
}}function getScrollBraWidth ()
{
try
{
var elem = document.createElement("DIV");
elem.id = "asdf";
elem.style.width = 200;
elem.style.height = 300;
elem.style.overflow = "scroll";
elem.style.position = "absolute";
elem.style.visibility = "hidden";
elem.style.top = "0";
elem.style.left = "0";
document.body.appendChild (elem);
scrollWidth = document.all['asdf'].offsetWidth - document.all['asdf'].clientWidth;
document.body.removeChild (elem);
delete elem;
}
catch (ex)
{
return false;
}
return scrollWidth;
}</SCRIPT><META content="MSHTML 6.00.2719.2200" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff onload="cloneHeader ();">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
if (window.print) {
document.write('<form>'+ '<input type=button name=print value="打印页面" '
+ 'onClick="javascript:doPrint()"></form>');
}
// End -->
</script>
<table id ="table1" width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>      <td bgcolor="#F2F2F2"  align="center" nowrap><font size="5" color=#000000>测试</font></td>
        </tr>
</table>
<center>
<DIV id=headerContainer style="Z-INDEX: 2; POSITION: absolute">
<TABLE id=upTbl style="tableLayout: fixed" bgColor=gray  border=1>
  <TBODY></TBODY></TABLE></DIV>
<DIV id=dataContainer 
style="Z-INDEX: 1; OVERFLOW: scroll; POSITION: relative; HEIGHT: 300px">
<SCRIPT language=JavaScript>
<!--
document.write(drawTab(rowNum, colNum, "", "data"));
document.all['dataContainer'].style.width = document.all['data'].offsetWidth + getScrollBraWidth ();
document.all['headerContainer'].style.width = document.all['data'].offsetWidth;
//-->
</SCRIPT>
</DIV>
</center>
</BODY></HTML>