public function write(array $data) { $this->init($data); fwrite($this->file, '<tr>'); foreach ($data as $value) { fwrite($this->file, sprintf('<td>%s</td>', $value)); } fwrite($this->file, '</tr>'); ++$this->position; }
public function testWithHeaders() { $writer = new XlsWriter($this->filename); $writer->open(); $writer->write(array('firtname' => 'john "2', 'surname' => 'doe', 'year' => '1')); $writer->close(); $expected = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name=ProgId content=Excel.Sheet><meta name=Generator content="https://github.com/sonata-project/exporter"></head><body><table><tr><th>firtname</th><th>surname</th><th>year</th></tr><tr><td>john "2</td><td>doe</td><td>1</td></tr></table></body></html>'; $this->assertEquals($expected, trim(file_get_contents($this->filename))); }