method toExcel documentation in bbn\Appui\Grid

Exports the grid's data or the given data to excel

function(array $data = []) { $path = X::makeStoragePath(\bbn\Mvc::getUserTmpPath()) . 'export_' . date('d-m-Y_H-i-s') . '.xlsx'; $cfg = $this->getExcel(); $dates = array_values(array_filter($cfg['fields'], function($c){ return empty($c['hidden']) && (($c['type'] === 'date') || ($c['type'] === 'datetime')); })); $data = array_map(function($row) use($cfg, $dates){ foreach ( $row as $i => $r ){ if ( \is_string($r) ){ $row[$i] = strpos($r, '=') === 0 ? ' '.$r : $r; } if ( (($k = X::find($dates, ['field' => $i])) !== null ) ){ if ( !empty($dates[$k]['format']) && !empty($r) ){ $r = date($dates[$k]['format'], strtotime($r)); } $row[$i] = \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($r); } if ( (($idx = X::find($cfg['fields'], ['field' => $i])) === null ) || (bool)$cfg['fields'][$idx]['hidden'] ){ unset($row[$i]); } } return $row; }, $data ?: ($this->getData() ?: [])); $cfg['fields'] = array_values(array_filter($cfg['fields'], function($c){ return empty($c['hidden']); })); if ( X::toExcel($data, $path, true, $cfg) ){ return ['file' => $path]; } return ['error' => X::_('Error')]; }

Exports the grid's data or the given data to excel BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.