1. The style of making reports in Word or Excel.
Excel's Row height and column width units cannot be represented in mm or cm.
needs to be calculated. Under 1024*768, the 1CM is about 38 pixels.
This is the benchmark for calculating and controlling the row and column positions of the report.
2. In Word, set "table--header row repeat."
In Excel, set the file--page Setup--sheet--print title.
3. Save as Web page, change suffix name "htm" as "jsp".
4. Word report file header is:
<%@page contentType="application/msword;charset=GBK" language="java"%>
The Excel report file header is:
<% @page contentType="application/vnd.ms-excel;charset=GBK" language="java"%>
5. Define the print parameter variables in the header section of the file as follows (for example, in Excel):
<%
//需要打印的记录条数
int PrintRowCount=RowCount;
//每页打印的记录条数
int PageRowCount=16;
//最后一页需要打印的空行的数目
int LoopNum=PageRowCount-PrintRowCount%PageRowCount;
//打印区域的高度,其中2的意思是每页需要重复的标题行的数目
int PrintAreaHeight=(PrintRowCount%PageRowCount==0)?PrintRowCount+2:PrintRowCount+LoopNum+2;
%>
6. After , change the!--[if GTE MSO 9] and! [XML tag content in the endif]--> tab, mainly setting the dynamic print area (for example, in Excel):
<%
out.print(" ......
"<x:ExcelName>"+
"<x:Name>Print_Area</x:Name>"+
"<x:SheetIndex>1</x:SheetIndex>"+
"<x:Formula>=Sheet1!$A$1:$G$"+PrintAreaHeight+"</x:Formula>"+
"</x:ExcelName>"+
...... ");
%>
7. Other code for JSP.
The following is the main loop print section (for example, in Excel):
<%
for (int i=1;i<=PrintRowCount; i++)
{
out.print("<tr>"<td>"+i+"</td></tr>"); //有内容
}
if (LoopNum!=PageRowCount) //有空行则打印空行补齐最末一页
for (int j=1;j<=LoopNum; j++)
{
out.print("<tr><td> </td></tr>");//无内容
}
%>
8. Test and continue to modify.