protected function render($objName, $separator=",", $ext="csv")
    {
        ob_end_clean();
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: public");
        header("Content-Description: File Transfer");
        header("Content-Type: application/vnd.ms-excel");
        header("Content-Disposition: filename=" . $objName."_".date('Y-m-d') . "." . $ext);
        header("Content-Transfer-Encoding: binary");

        $dataTable = $this->getDataTable($objName);
        foreach ($dataTable as $row)
        {
            $line = "";
            foreach ($row as $cell) {
                $txt = $this->strip_cell($cell);
                //if (!empty($txt))
				//Changed condition from empty()to is_null() to allow null fields from being truncated out when csv generated (cyril ogana 2011-11-11)
				//TODO: Need to add condition to leave out fields which have no column name e.g. the first field which has rowcheckboxes?
				if (!is_null($txt))
                    $line .= "\"" . $txt . "\"$separator";
            }
            $line = rtrim($line, $separator);
            $line = iconv("UTF-8","GB2312//IGNORE",$line);
            echo rtrim($line) . "\n";
        }
    }
protected function render($objName, $separator=",", $ext="csv")
    {
        ob_end_clean();
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: public");
        header("Content-Description: File Transfer");
        header("Content-Type: application/vnd.ms-excel");
        header("Content-Disposition: filename=" . $objName."_".date('Y-m-d') . "." . $ext);
        header("Content-Transfer-Encoding: binary");

        $dataTable = $this->getDataTable($objName);
        foreach ($dataTable as $row)
        {
            $line = "";
            foreach ($row as $cell) {
                $txt = $this->strip_cell($cell);
                //if (!empty($txt))
				//Changed condition from empty()to is_null() to allow null fields from being truncated out when csv generated (cyril ogana 2011-11-11)
				//TODO: Need to add condition to leave out fields which have no column name e.g. the first field which has rowcheckboxes?
				if (!is_null($txt))
                    $line .= "\"" . $txt . "\"$separator";
            }
            $line = rtrim($line, $separator);
            $line = iconv("UTF-8","GB2312//IGNORE",$line);
            echo rtrim($line) . "\n";
        }
    }
protected function render ( $ objName , $ separator = "," , $ ext = "csv" ) { ob_end_clean ( ) ; header ( "Pragma: public" ) ; header ( "Expires: 0" ) ; header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ) ; header ( "Cache-Control: public" ) ; header ( "Content-Description: File Transfer" ) ; header ( "Content-Type: application/vnd.ms-excel" ) ; header ( "Content-Disposition: filename=" . $ objName . "_" . date ( 'Y-m-d' ) . "." . $ ext ) ; header ( "Content-Transfer-Encoding: binary" ) ; $ dataTable = $ this -> getDataTable ( $ objName ) ; foreach ( $ dataTable as $ row ) { $ line = "" ; foreach ( $ row as $ cell ) { $ txt = $ this -> strip_cell ( $ cell ) ; //if (!empty($txt)) //Changed condition from empty()to is_null() to allow null fields from being truncated out when csv generated (cyril ogana 2011-11-11) //TODO: Need to add condition to leave out fields which have no column name e.g. the first field which has rowcheckboxes? if ( ! is_null ( $ txt ) ) $ line .= "\"" . $ txt . "\"$separator" ; } $ line = rtrim ( $ line , $ separator ) ; $ line = iconv ( "UTF-8" , "GB2312//IGNORE" , $ line ) ; echo rtrim ( $ line ) . "\n" ; } }
Render excel data

@param string $objName object form name
@param string $separator sparator between column
@param string $ext file extension
@return void
Render excel data