/** * Description... * * @return void **/ public function _dataForExcel(RM_Excel_Sheet $sheet) { $mapCompleted = 0; $map = array(); if ($this->dynamic()) { $res = array(); foreach ($this->_collectRows(qw2('type>Excel')) as $data) { $sheet->addRow(array_merge(array('0' => $data['name']), $data['data'])); if (!$mapCompleted) { $map[] = 'default'; for ($i = 0; $i < count($data['data']); $i++) { $map[] = $data['format']; } $sheet->setColumnFormat($map); $mapCompleted = 1; } } } else { foreach ($this->reportRequest() as $row) { $data = array(); $data[] = $this->getRowCaption($row); if (!$mapCompleted) { $map[] = 'default'; } foreach ($this->_object->values() as $item) { $data[] = $item->show($row, qw2('type>Excel')); if (!$mapCompleted) { $map[] = $item->excelFormat(); } } $sheet->addRow($data); if (!$mapCompleted) { $sheet->setColumnFormat($map); $mapCompleted = 1; } } } }
/** * Enter description here... * * @param RM_Excel_Sheet $sheet * @param mixed<array|RM_Store_Request> $data */ protected function _prepareData(RM_Excel_Sheet $sheet, $data) { if (is_array($data)) { // if array of array if (is_array(current($data))) { foreach ($data as $row) { $sheet->addRow($row); } } else { $sheet->addRow($data); } } elseif (is_object($data)) { foreach ($data as $cols) { $tmp = array(); foreach ($cols as $value) { $tmp[] = $value; } $sheet->addRow($tmp); } } }