Conditions | 4 |
Paths | 4 |
Total Lines | 27 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
18 | public function writeXls($html) { |
||
19 | |||
20 | $htmlFile = str_replace('.xls', '.html', static::XLS_FILE); |
||
21 | $htmlRes = file_put_contents($this->getDocumentRoot() . static::TMP_FOLDER . $htmlFile, $html); |
||
22 | |||
23 | if($htmlRes) { |
||
24 | |||
25 | //TODO: check size !!! |
||
26 | chdir($this->getDocumentRoot() . static::TMP_FOLDER); |
||
27 | $command = sprintf("libreoffice --calc --convert-to xls %s", $htmlFile); |
||
28 | exec($command); |
||
29 | if(file_exists($this->getTmpXlsFile())) { |
||
30 | unlink($this->getDocumentRoot() . static::TMP_FOLDER . $htmlFile); |
||
31 | $command = sprintf("mv %s %s", $this->getTmpXlsFile(), $this->getXlsFile()); |
||
32 | exec($command); |
||
33 | return filesize($this->getXlsFile()); |
||
34 | } |
||
35 | |||
36 | } else { |
||
37 | /** @var LoggerInterface $logger */ |
||
38 | $logger = $this->getLogger(); |
||
39 | if($logger) { |
||
40 | $logger->error($this->getName() . ' ERROR: unable write file!'); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | return 0; |
||
45 | } |
||
47 |