public function __construct($classDirectory = null) { parent::__construct(); $this->classesDir = $classDirectory; $this->locatorFile = PHPExt::getTempDir() . '/ClassLocator' . md5(var_export($classDirectory, true)) . '.ser'; self::$log->trace("Locator File: {$this->locatorFile}"); }
public static function output($table, $name = '') { error_reporting(0); if (!is_object($table) && !is_array($table)) { exit; } if ($name == '') { $name = 'output' . Invocation::next(); } if (!preg_match('/^.*\\.xls$/i', $name)) { $name .= '.xls'; } $fileName = PHPExt::getTempDir() . '/' . $name; $workbook = new Spreadsheet_Excel_Writer($fileName); $worksheet =& $workbook->addWorksheet(basename($name)); $rowIdx = 0; if ($table instanceof DBTable || is_array($table)) { foreach ($table as $row) { if ($rowIdx == 0) { foreach (array_keys($row) as $col => $heading) { $worksheet->write($rowIdx, $col, $heading); } $rowIdx++; } foreach (array_values($row) as $col => $val) { $worksheet->write($rowIdx, $col, $val); } $rowIdx++; } } else { if ($table instanceof PDOStatement) { while ($row = $table->fetch(DB::FETCH_ASSOC)) { if ($rowIdx == 0) { foreach (array_keys($row) as $col => $heading) { $worksheet->write($rowIdx, $col, $heading); } $rowIdx++; } foreach (array_values($row) as $col => $val) { $worksheet->write($rowIdx, $col, $val); } $rowIdx++; } } } $workbook->close(); $workbook->send($name); $fp = fopen($fileName, 'rb'); fpassthru($fp); fclose($fp); unlink($fileName); exit; }