分页取数存入数组的一段示例代码

  1. private function _get_content_list()   
  2.    {   
  3.        $temp_content_list ;   
  4.           
  5.        $ExpandedRowCount = 1;   
  6.        if(!is_null($this->excel_content) && is_array($this->excel_content))   
  7.        {   
  8.            $cell_keys = array_keys($this->excel_header);   
  9.                           
  10.            $total_rows = count($this->excel_content);   
  11.                                       
  12.            $temp_content = '';   
  13.            $page_index = 1;   
  14.            for($i = 0; $i < $total_rows$i ++)   
  15.            {   
  16.                //拼$temp_content   
  17.                $content_item = $this->excel_content[$i];   
  18.                //关键点1   
  19.                if(!is_null($content_item) && is_array($content_item))   
  20.                {   
  21.                    $temp_content .= "<Row>";   
  22.                    foreach($cell_keys as $cell_name)   
  23.                    {   
  24.                        if(isset($content_item[$cell_name]))   
  25.                        {   
  26.                            $temp_content .= '<Cell><Data ss:Type="String">' . $this->_trans_xml_char($content_item[$cell_name]) . '</Data></Cell>';   
  27.                        }   
  28.                    }   
  29.                    $temp_content .= "</Row>";   
  30.                    $ExpandedRowCount ++;   
  31.                }     
  32.                //关键点2                      
  33.                if($page_index * Excel::ROWS_WORK_SHEET == ($i + 1))                   
  34.                {                                      
  35.                    $temp_content_list[] = array("content"=>$temp_content"expandedRowCount"=>$ExpandedRowCount);   
  36.                    $temp_content = '';   
  37.                    $ExpandedRowCount = 1;   
  38.                    $page_index ++;   
  39.                }                   
  40.            }   
  41.               
  42.            //关键点3   
  43.            if($total_rows % Excel::ROWS_WORK_SHEET > 0)   
  44.               $temp_content_list[] = array("content"=>$temp_content"expandedRowCount"=>$ExpandedRowCount);     
  45.        }   
  46.                   
  47.        return $temp_content_list;   
  48.    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值