faisalman / simple-excel-php

Simplexcel.php - Easily read / parse / convert / write between Microsoft Excel XML / CSV / TSV / HTML / JSON / etc spreadsheet tabular file formats

Home Page:http://faisalman.github.io/simple-excel-php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug abstract method

opened this issue · comments

I tried to use the library but got error trying to use the example code

Fatal error: Class SimpleExcel\Writer\XMLWriter contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SimpleExcel\Writer\IWriter::saveFile) in D:\htdocs\libraries\SimpleExcel\Writer\XMLWriter.php on line 154

Ah yes you're right, thanks for spotting that. Since XMLWriter implements IWriter there should be a saveFile() method in XMLWriter.php, like in BaseWriter.php line 80

    /**
     * Export the document
     * 
     * @param   string  $filename   Name for the saved file (extension will be set automatically)
     * @param   string  $target     Save location
     * @return  void
     */
    public function saveFile($filename, $target = NULL){

        if (!isset($filename)) {
            $filename = date('YmdHis');
        }
        if (!isset($target)) {
            // write output to browser
            $target = 'php://output';
        }

        // set HTTP response header
        header('Content-Type: '.$this->content_type);
        header('Content-Disposition: attachment; filename='.$filename.'.'.$this->file_extension);

        $fp = fopen($target, 'w');
        fwrite($fp, $this->getAsString());
        fclose($fp);

        if ($target == 'php://output') {
            // since there must be no data below
            exit();
        }
    }

I believe, that the function call on line 95 should rename in saveString()...

Oh yes that one too... thanks for spotting that, I forgot to fix that after renaming earlier method in this commit: 08a7565