/** * Returns the output as an Excel spreadsheet. * * @param bool $renderHeaders Set to false to supress headers in the spreadsheet (defaults to true). * * @return string * * @since 1.0 */ public function render($renderHeaders = true) { self::$logger->debug('>>render()'); //define separator (tabbed character) $sep = "\t"; $output = ''; // get the class attributes $reflection = new \ReflectionClass(get_class($this->BO)); $properties = $reflection->getProperties(); // print headers if ($renderHeaders) { $output .= $this->BO->getDataLabel('OID') . $sep; foreach ($properties as $propObj) { $propName = $propObj->name; if (!in_array($propName, $this->BO->getTransientAttributes()) && !in_array($propName, $this->BO->getDefaultAttributes())) { $output .= $this->BO->getDataLabel($propName) . $sep; } } $output .= "\n"; } // print values $output .= $this->BO->getOID() . $sep; foreach ($properties as $propObj) { $propName = $propObj->name; $prop = $this->BO->getPropObject($propName); if (!in_array($propName, $this->BO->getTransientAttributes()) && !in_array($propName, $this->BO->getDefaultAttributes())) { if (get_class($prop) == 'DEnum') { $output .= $prop->getDisplayValue() . $sep; } elseif (get_class($prop) == 'Relation') { $output .= $prop->getRelatedClassDisplayFieldValue() . $sep; } else { $output .= preg_replace("/[\n\r]/", '', $prop->getValue()) . $sep; } } } $output .= "\n"; self::$logger->debug('<<render'); return $output; }