- private function _get_content_list()
- {
- $temp_content_list ;
- $ExpandedRowCount = 1;
- if(!is_null($this->excel_content) && is_array($this->excel_content))
- {
- $cell_keys = array_keys($this->excel_header);
- $total_rows = count($this->excel_content);
- $temp_content = '';
- $page_index = 1;
- for($i = 0; $i < $total_rows; $i ++)
- {
- //拼$temp_content
- $content_item = $this->excel_content[$i];
- //关键点1
- if(!is_null($content_item) && is_array($content_item))
- {
- $temp_content .= "<Row>";
- foreach($cell_keys as $cell_name)
- {
- if(isset($content_item[$cell_name]))
- {
- $temp_content .= '<Cell><Data ss:Type="String">' . $this->_trans_xml_char($content_item[$cell_name]) . '</Data></Cell>';
- }
- }
- $temp_content .= "</Row>";
- $ExpandedRowCount ++;
- }
- //关键点2
- if($page_index * Excel::ROWS_WORK_SHEET == ($i + 1))
- {
- $temp_content_list[] = array("content"=>$temp_content, "expandedRowCount"=>$ExpandedRowCount);
- $temp_content = '';
- $ExpandedRowCount = 1;
- $page_index ++;
- }
- }
- //关键点3
- if($total_rows % Excel::ROWS_WORK_SHEET > 0)
- $temp_content_list[] = array("content"=>$temp_content, "expandedRowCount"=>$ExpandedRowCount);
- }
- return $temp_content_list;
- }
分页取数存入数组的一段示例代码
最新推荐文章于 2024-10-11 09:50:52 发布