方枪枪的java世界

不要因为风雨飘落就停止了你的脚步,真正的得失就在你的心中。 做喜欢做的事,不轻言放弃!

cell 报表制作脚本举例

 

<%@ page contentType="text/html;charset=GBK"%>
<%@ taglib uri="/tags/web-html" prefix="html"%>
<%@ taglib uri="/tags/web-tianhe" prefix="templates"%>
<%@ page import="java.math.BigDecimal"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.Date"%>


<script language="Jscript">

function setfilename()
{
  filen="jsp/hr/personnel/Personnelreport.cll";  
  return filen;
}
function filldata()
{
<%
   List bodyList=(List)request.getAttribute("bodyList");  //表体数据
   Map headTailMap=(Map)request.getAttribute("headTailMap");  //表头表尾数据
  
   int len = bodyList.size();
   String title= (String) headTailMap.get("title");//标题
      String userName=(String)headTailMap.get("userName");//制表人
      String date=(String)headTailMap.get("dateId");//制表时间
%>
     sheet = <%=0%>;
  content_col=1;
  //设置某页行数
  CellRpt.SetRows(<%=len+4+1%>,sheet);//设置某页行数(行数,页号)
  CellRpt.SetCols(15,sheet);//设置某页列数(列数,页号)
  CellRpt.PrintSetOrient(1);//设置进纸方式为横放

  CellRpt.MergeCells(1,1,15,1);//将指定区域的单元格组合(区域起始点列号,行号,区域结束点列号,行号)
  CellRpt.SetCellFontStyle(1,1,sheet,2);//设置指定单元格的字体风格(列号,行号,页号,字体风格)
   CellRpt.SetCellFontSize(1,1,sheet,20);//设置单元格字体大小(列号,行号,页号,字号)
  CellRpt.SetCellAlign(1,1,sheet,36);//设置指定单元格的对齐方式(列号,行号,页号,参数)
  CellRpt.S(1,1,sheet,"<%=title%>");

  CellRpt.MergeCells(1,2,1,2);
  CellRpt.SetCellFontStyle(1,2,sheet,3);
   CellRpt.SetCellFontSize(1,2,sheet,10);
  CellRpt.SetCellAlign(1,2,sheet,36);
  CellRpt.S(1,2,sheet,"部门");

  CellRpt.MergeCells(2,2,2,2);
  CellRpt.SetCellFontStyle(2,2,sheet,3);
   CellRpt.SetCellFontSize(2,2,sheet,10);
  CellRpt.SetCellAlign(2,2,sheet,36);
  CellRpt.S(2,2,sheet,"姓名");

  CellRpt.MergeCells(3,2,3,2);
  CellRpt.SetCellFontStyle(3,2,sheet,3);
   CellRpt.SetCellFontSize(3,2,sheet,10);
  CellRpt.SetCellAlign(3,2,sheet,36);
  CellRpt.S(3,2,sheet,"性别");

  CellRpt.MergeCells(4,2,4,2);
  CellRpt.SetCellFontStyle(4,2,sheet,3);
   CellRpt.SetCellFontSize(4,2,sheet,10);
  CellRpt.SetCellAlign(4,2,sheet,36);
  CellRpt.S(4,2,sheet,"年龄");

  CellRpt.MergeCells(5,2,5,2);
  CellRpt.SetCellFontStyle(5,2,sheet,3);
   CellRpt.SetCellFontSize(5,2,sheet,10);
  CellRpt.SetCellAlign(5,2,sheet,36);
  CellRpt.S(5,2,sheet,"政治面貌");

  CellRpt.MergeCells(6,2,6,2);
  CellRpt.SetCellFontStyle(6,2,sheet,3);
   CellRpt.SetCellFontSize(6,2,sheet,10);
  CellRpt.SetCellAlign(6,2,sheet,36);
  CellRpt.S(6,2,sheet,"学历");

  CellRpt.MergeCells(7,2,7,2);
  CellRpt.SetCellFontStyle(7,2,sheet,3);
   CellRpt.SetCellFontSize(7,2,sheet,10);
  CellRpt.SetCellAlign(7,2,sheet,36);
  CellRpt.S(7,2,sheet,"专业技术名称");

  CellRpt.MergeCells(8,2,8,2);
  CellRpt.SetCellFontStyle(8,2,sheet,3);
   CellRpt.SetCellFontSize(8,2,sheet,10);
  CellRpt.SetCellAlign(8,2,sheet,36);
  CellRpt.S(8,2,sheet,"职业技能名称");

  CellRpt.MergeCells(9,2,9,2);
  CellRpt.SetCellFontStyle(9,2,sheet,3);
   CellRpt.SetCellFontSize(9,2,sheet,10);
  CellRpt.SetCellAlign(9,2,sheet,36);
  CellRpt.S(9,2,sheet,"出生日期");

  CellRpt.MergeCells(10,2,10,2);
  CellRpt.SetCellFontStyle(10,2,sheet,3);
   CellRpt.SetCellFontSize(10,2,sheet,10);
  CellRpt.SetCellAlign(10,2,sheet,36);
  CellRpt.S(10,2,sheet,"入职时间");
 
  CellRpt.MergeCells(11,2,11,2);
  CellRpt.SetCellFontStyle(11,2,sheet,3);
   CellRpt.SetCellFontSize(11,2,sheet,10);
  CellRpt.SetCellAlign(11,2,sheet,36);
  CellRpt.S(11,2,sheet,"家庭地址");
 
  CellRpt.MergeCells(12,2,12,2);
  CellRpt.SetCellFontStyle(12,2,sheet,3);
   CellRpt.SetCellFontSize(12,2,sheet,10);
  CellRpt.SetCellAlign(12,2,sheet,36);
  CellRpt.S(12,2,sheet,"办公电话");
 
  CellRpt.MergeCells(13,2,13,2);
  CellRpt.SetCellFontStyle(13,2,sheet,3);
   CellRpt.SetCellFontSize(13,2,sheet,10);
  CellRpt.SetCellAlign(13,2,sheet,36);
  CellRpt.S(13,2,sheet,"移动电话");
 
  CellRpt.MergeCells(14,2,14,2);
  CellRpt.SetCellFontStyle(14,2,sheet,3);
   CellRpt.SetCellFontSize(14,2,sheet,10);
  CellRpt.SetCellAlign(14,2,sheet,36);
  CellRpt.S(14,2,sheet,"员工状态");
 
     content_row=3;

<%
  BigDecimal sumEmpNum = new BigDecimal(bodyList.size());

        for(int i = 0;i < bodyList.size();i++){
       Map  bodyMap = (Map) bodyList.get(i);
       String orgName = (String)bodyMap.get("ORGAN_NAME");//部门
    String empName = (String)bodyMap.get("EMP_NAME");//员工姓名
    String sex = (String)bodyMap.get("SEX");//性别
    String policital = (String)bodyMap.get("POLICITAL_STATUS");//政治面貌
    String edu = (String)bodyMap.get("EDUCATION");//学历
    String tName = (String)bodyMap.get("NAME");//专业技术名称
    String skillName = (String)bodyMap.get("SKILL_POST_NAME");//职业技能名称
    String birthday = (String)bodyMap.get("BIRTHDAY");//生日
    String entryDay = (String)bodyMap.get("ENTRY_ENTERPRISE_DAT");//入职时间
    String addr = (String)bodyMap.get("ADDRESS");//家庭住址
    String officePhone = (String)bodyMap.get("OFFICE_PHONE");//办公电话
    String mobilePhone = (String)bodyMap.get("MOBILE_PHONE");//移动电话
    String state = (String)bodyMap.get("STATE");//员工状态
    String ageStr = "";
    if(sex == null || "".equals(sex)){
     sex = "";
    }else{
     switch(Integer.parseInt(sex)){
     case 0 : sex="男";break;
     case 1 : sex="女";break;
     } 
    }
    if(policital == null || "".equals(policital)){
     policital = "";
    }else{
     switch(Integer.parseInt(policital)){
     case 1 : policital="工人";break;
     case 2 : policital="农民";break;
     case 3 : policital="知识分子";break;
     case 4 : policital="群众";break;
     } 
    }
    if(edu == null || "".equals(edu)){
     edu = "";
    }else{
     switch(Integer.parseInt(edu)){
     case 1 : edu="小学";break;
     case 2 : edu="初中";break;
     case 3 : edu="高中";break;
     case 4 : edu="大学专科";break;
     case 5 : edu="大学本科";break;
     case 6 : edu="硕士";break;
     case 7 : edu="博士";break;
     } 
    }
    if(skillName == null || "".equals(skillName)){
     skillName = "";
    }else{
     switch(Integer.parseInt(skillName)){
     case 1 : skillName="企业人力资源管理";break;
     case 2 : skillName="计算机操作";break;
     case 3 : skillName="仓储工";break;
     case 4 : skillName="企业经营管理";break;
     case 5 : skillName="秘书";break;
     case 6 : skillName="物流管理";break;
     case 7 : skillName="卷烟商品营销";break;
     case 8 : skillName="客户服务管理";break;
     case 9 : skillName="企业信息管理";break;
     case 10 : skillName="汽车驾驶";break;
     case 11 : skillName="营业员";break;
     } 
    }
    if(birthday == null || "".equals(birthday)){
     birthday = "";
    }else{
     String yearBir = birthday.substring(0,4);
     String dateNow = new Date().toString();
     String yearNow = dateNow.substring(dateNow.length()-4,dateNow.length());
     int ageInt = Integer.parseInt(yearNow) - Integer.parseInt(yearBir);
     ageStr = String.valueOf(ageInt); 
    }
%>
        content_col=1;
   CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
  CellRpt.SetCellAlign(content_col,content_row,sheet,33);
  CellRpt.S(content_col,content_row,sheet,"<%=orgName%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,33);
  CellRpt.S(content_col,content_row,sheet,"<%=empName%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,33);
  CellRpt.S(content_col,content_row,sheet,"<%=sex%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=ageStr%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=policital%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=edu%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=tName%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=skillName%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=birthday%>");
  content_col++;
 
  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=entryDay%>");
  content_col++;
 
  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=addr%>");
  content_col++;
 
  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=officePhone%>");
  content_col++;
 
  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=mobilePhone%>");
  content_col++;
 
  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=state%>");

  content_row++;
<%

}
%>
  content_col=1;
  CellRpt.MergeCells(content_col,content_row,content_col,content_row);
  CellRpt.SetCellFontStyle(content_col,content_row,sheet,0);
  CellRpt.SetCellAlign(content_col,content_row,sheet,33);
  CellRpt.S(content_col,content_row,sheet,"合计");

  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=sumEmpNum%>(人)");//总人数

 
  content_row++;
 
 
  CellRpt.MergeCells(1,content_row,3,content_row);
  CellRpt.SetCellFontSize(1,content_row,sheet,10);
   CellRpt.SetCellAlign(1,content_row,sheet,33);
  CellRpt.S(1,content_row,sheet,"制表人:"+"<%=userName%>");

  CellRpt.MergeCells(12,content_row,14,content_row);
  CellRpt.SetCellFontSize(12,content_row,sheet,10);
   CellRpt.SetCellAlign(12,content_row,sheet,34);
  CellRpt.S(12,content_row,sheet,"制表日期:"+"<%=date%>");

   var line_rowBegin=2; //从第二行开始
  var line_rowEnd=CellRpt.getRows(sheet)-2; //画到倒数第三行
  var line_colBegin=1; //从第一列开始
  var line_colEnd=CellRpt.getCols(sheet);//画到最后一列
  CellRpt.DrawGridLine(line_colBegin, line_rowBegin, line_colEnd,line_rowEnd, 0, 2,-1);//所有框画细线
 
  //打印设置
   CellRpt.PrintRange(1,1,CellRpt.getCols(sheet),CellRpt.getRows(sheet));
  CellRpt.PrintSetTopTitle(1,6);
  CellRpt.PrintSetBottomTitle(content_row+1,content_row+1);
  CellRpt.PrintSetOrient(1);//打印方向:1为横向,0为纵向
}

</script>

posted on 2008-04-05 23:58 做强大的自己 阅读(706) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: