Tell pzhl how to fill the Region column through a loop (foreach)
<?php $query="select f.full_name f_name,d.* from zrdt.report_detail d,zrdt.filial f where f.id=d.filial_id and report_id=".$report_id." and report_result_id=".$report_result_id." order by filial_id" ; //echo $query;exit; $database->setQuery( $query ); $rows = $database->loadObjectList(); $xml_data_begin='<?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"> <Author>Nurzhaubay AN</Author> <LastAuthor>Radmin</LastAuthor> <Created>1980-02-15T00:00:01Z</Created> <Version>12.00</Version> </DocumentProperties> <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> <ProtectStructure>False</ProtectStructure> <ProtectWindows>False</ProtectWindows> </ExcelWorkbook> <Worksheet ss:Name="Result">'; $xml_data_end='<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"> <ProtectObjects>False</ProtectObjects> <ProtectScenarios>False</ProtectScenarios> </WorksheetOptions> </Worksheet> </Workbook>'; if (ob_get_level()) {ob_end_clean();} // header('Content-Description: File Transfer'); header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=employee.xml"); echo $xml_data_begin; //Наименование столбца(Колонка-РЕГИОН) echo '<Table x:FullColumns="1" x:FullRows="1" ss:DefaultRowHeight="15"> <Row ss:AutoFitHeight="0"> <Cell><Data ss:Type="String">'.mb_convert_encoding("Регион", "utf-8","windows-1251").'</Data></Cell> </Row> </Table>'; //Для каждого региона из запроса в БД ($query) foreach($rows as $row) { echo '<Row ss:AutoFitHeight="0">'; echo '<Cell><Data ss:Type="String">'.mb_convert_encoding(trim($row->F_NAME), "utf-8","windows-1251").'</Data></Cell>'; echo '</Row>\n'; } echo $xml_data_end; exit(); ?>
try { $database->setQuery($query); $rows = $database->loadObjectList(); echo "count: " . count($rows); } catch (\RuntimeException $e) { echo $e->getMessage(); } exit;try { $database->setQuery($query); $rows = $database->loadObjectList(); echo "count: " . count($rows); } catch (\RuntimeException $e) { echo $e->getMessage(); } exit;- Jigius