如果我一个页面只能显示10条记录.  而查询数据库却得到30条记录或大于10条记录.
要如何实现分页呢??      谢谢!  

解决方案 »

  1.   

    接分
    PS: 
    我的目标是 ----> ^_^
      

  2.   

    <script type="text/javascript">
            var CellFilePath="Cell/templates/De05.cll";
            function FillData()
            {
                celBill=form1.celBill;
                var pageSize=21;
                var pageCount;  
                var startIndex=0; 
                var dt=Cell_Reports_De5.GetALLReport().value;
                var recordCount=dt.Rows.length;
                if (recordCount%pageSize==0)
                {
                    pageCount=parseInt(recordCount/pageSize);
                }
                else
                {
                    pageCount=parseInt(recordCount/pageSize)+1;
                }            if (dt!=null)
                {
                  form1.celBill.Login("用友U8管理软件","","13040259", "4040-1150-0161-5005");
                  form1.celBill.OpenFile("<%=PublicFunction.WebSitePath() %>"+CellFilePath,"");
    //              form1.celBill.Readonly =false;
    //              form1.celBill.ProtectSheet(0,1);
    //              form1.celBill.ShowTopLabel(0,0);
    //              form1.celBill.ShowSideLabel(0,0);
                  var cellobj=form1.celBill;
                  
                  for (var z=0;z<pageCount;z++)
                  {
                    if (pageCount>1)
                    {
                        cellobj.AppendSheetFromFile("<%=PublicFunction.WebSitePath() %>"+CellFilePath,0,z-1);
                    }
                    
                    cellobj.SetSheetLabel(z,"第"+(z+1)+"页");
                    cellobj.SetCurSheet(z);
                    
    //                cellobj.Readonly =true;
    //                cellobj.ProtectSheet(z,"");
    //                
    //                cellobj.ShowTopLabel(0,z);
    //                cellobj.ShowSideLabel(0,z);
                    
                    pageIndex=z+1;
                    
                    startIndex=(pageIndex-1)*pageSize;
                    cellobj.SetCellAlign(14,3,z, 4+32);
                    cellobj.SetCellString(14,3,z,"第"+pageIndex+"页");
                    
                    cellobj.SetCellAlign(15,3,z, 4+32);
                    cellobj.SetCellString(15,3,z,"共"+pageCount+"页 ");
                    
                    startIndex=(pageIndex-1)*pageSize;
                  
                      for (var i = startIndex;i < startIndex+pageSize&&i<recordCount;i++)
                      {
                            form1.celBill.SetCellAlign(2,i+7-startIndex,z,4+32)
                            form1.celBill.SetCellString(2,i+7-startIndex,z,i+1);//序号
                            
                            form1.celBill.SetCellAlign(3,i+7-startIndex,z,1+32)
                            form1.celBill.SetCellString(3,i+7-startIndex,z,replaceStr(dt.Rows[i].deh));//定额编号
                            
                         
                            form1.celBill.SetCellAlign(5,i+7-startIndex,z,1+32)
                            form1.celBill.SetCellString(5,i+7-startIndex,z,replaceStr(dt.Rows[i].xmmc));//项目名称
                            form1.celBill.SetCellTextStyle(5,i+7-startIndex,z,2);
                            form1.celBill.SetCellTextLineSpace(5,i+7-startIndex,z,1);
                            form1.celBill.SetCellAlign(6,i+7-startIndex,z,4+32)
                            form1.celBill.SetCellString(6,i+7-startIndex,z,replaceStr(dt.Rows[i].xmdw));//项目单位
                            
                            form1.celBill.SetCellAlign(7,i+7-startIndex,z,2+32)
                            form1.celBill.SetCellString(7,i+7-startIndex,z,replaceStr(dt.Rows[i].gcl));//数量
                            
                            form1.celBill.SetCellAlign(8,i+7-startIndex,z,2+32)
                            form1.celBill.SetCellString(8,i+7-startIndex,z,replaceStr(dt.Rows[i].sjjj));//基价
                            
                            form1.celBill.SetCellAlign(9,i+7-startIndex,z,2+32)
                            form1.celBill.SetCellString(9,i+7-startIndex,z,replaceStr(dt.Rows[i].jj));//基价合价
                            
                            form1.celBill.SetCellAlign(10,i+7-startIndex,z,2+32)
                            form1.celBill.SetCellString(10,i+7-startIndex,z,replaceStr(dt.Rows[i].sjrgf));//人工费
                            
                            form1.celBill.SetCellAlign(11,i+7-startIndex,z,2+32)
                            form1.celBill.SetCellString(11,i+7-startIndex,z,replaceStr(dt.Rows[i].rgf));//人工费合价
                            
                            form1.celBill.SetCellAlign(12,i+7-startIndex,z,2+32)
                            form1.celBill.SetCellString(12,i+7-startIndex,z,replaceStr(dt.Rows[i].sjclf));//材料费
                            
                            form1.celBill.SetCellAlign(13,i+7-startIndex,z,2+32)
                            form1.celBill.SetCellString(13,i+7-startIndex,z,replaceStr(dt.Rows[i].clf));//材料费合价
                            
                            form1.celBill.SetCellAlign(14,i+7-startIndex,z,2+32)
                            form1.celBill.SetCellString(14,i+7-startIndex,z,replaceStr(dt.Rows[i].sjjxf));//机械费
                            
                            form1.celBill.SetCellAlign(15,i+7-startIndex,z,2+32)
                            form1.celBill.SetCellString(15,i+7-startIndex,z,replaceStr(dt.Rows[i].jxf));//机械费合价
                            
                            var height1=form1.celBill.GetRowBestHeight(i+7-startIndex);
                            var height2=form1.celBill.GetRowHeight(1,i+7-startIndex,z);
                            if(height1>height2)
                            {
                               form1.celBill.SetRowHeight(1,height1,i+7-startIndex,z);
                            }
                     }
    //                 var col=form1.celBill.GetColBestWidth(5)  //获得最合适列宽
    //                 form1.celBill.SetColWidth(1,col,5,z);//设置成适合宽度
                 }      
                }
            }
            
            function  psetup()
            {
                form1.celBill.PrintPageSetup();
            }
           
            function printBill()
            {
                form1.celBill.PrintPara(1,0,0,0);
                form1.celBill.PrintSheet(1,0);
            }
            
            function PrintPreview()
            {
                form1.celBill.PrintPreview(1,form1.celBill.GetCurSheet());
            }
            
            function ExportBill()
            {
                form1.celBill.ExportExcelDlg();
        }
          
        </script>
    项目里应用的
      

  3.   


      呵呵.. 谢谢了.!
    你这种是分成sheet..   我说的分页是在一个sheet里面根据用户自己定义的模板,如果数据行超过模板定义的行 .. 就需要分页现实.  
         不是多添加sheet也表