public function addFromString($localname, $contents)
    {
        $filenameParts = pathinfo($localname);

        $handle = fopen($this->tempDir.'/'.$filenameParts["basename"], "wb");
        fwrite($handle, $contents);
        fclose($handle);

        $res = $this->zip->add($this->tempDir.'/'.$filenameParts["basename"], PCLZIP_OPT_REMOVE_PATH, $this->tempDir, PCLZIP_OPT_ADD_PATH, $filenameParts["dirname"]);
        if ($res == 0) {
            throw new PHPExcel_Writer_Exception("Error zipping files : " . $this->zip->errorInfo(true));
        }

        unlink($this->tempDir.'/'.$filenameParts["basename"]);
    }