_filename = substr($filename, 0 , strpos($filename, ".")); } /* public function addData() */ function addData($data) { if(is_array($data)) { $this->_data = $data; $this->renderContent(); } } /* private function renderContent() */ function renderContent() { $this->_renderedContent = ""; $badsigns = array("\t", "\r", "\n"); $goodsigns = array(" ", "", ""); foreach($this->_data as $row) { $rowstring = ""; foreach($row as $field) { $rowstring .= str_replace($badsigns, $goodsigns, utf8_decode(stripslashes($field))) . "\t"; } $this->_renderedContent .= substr($rowstring, 0, -1) . "\r\n"; } } /* public function sendData() */ function sendData() { header("Content-type: application/vnd.ms-excel"); header('Content-Disposition: attachment; filename="' . $this->_filename . '_' . date("d-m-Y") . '.xls"'); echo $this->_renderedContent; } }