'factuurnummer', 'B' => 'project', 'C' => 'klant', 'D' => 'factuurdatum', 'E' => 'exc btw', 'F' => 'btw', 'G' => 'incl btw' ]; private $invoiced; private $sheet; private $row; public function __construct( $invoiced, $sheet ) { $this->invoiced = $invoiced; $this->sheet = $sheet; $this->handle(); } private function handle() { $this->setHeader(); $this->setBody(); } private function setHeader() { foreach ( self::HEADERS as $cell => $header ) { $this->sheet->setCellValue( $cell . '1', $header ); $this->sheet->getColumnDimension( $cell )->setAutoSize( TRUE ); } } private function setBody() { $this->row = 2; foreach ( $this->invoiced AS $invoice ) { $vat = ROUND($invoice->invoiceamount * 0.21, 2); $this->sheet->setCellValue( 'A' . $this->row, $invoice->invoicenumber ); $this->sheet->setCellValue( 'B' . $this->row, ($invoice->projectnumber . ' ' . $invoice['projectname'])); $this->sheet->setCellValue( 'C' . $this->row, $invoice->name ); $this->sheet->setCellValue( 'D' . $this->row, $invoice->invoicenumber ); $this->sheet->setCellValue( 'E' . $this->row, $invoice->invoiceamount ); $this->sheet->setCellValue( 'F' . $this->row, $vat ); $this->sheet->setCellValue( 'G' . $this->row, $invoice->invoiceamount + $vat ); $this->row ++; } } }