T
T
thisuser2018-03-20 12:53:55
PHP
thisuser, 2018-03-20 12:53:55

PHP Excel. Why is not a "complete" file formed?

Greetings! I take the .csv
file and convert it to .xlsx in this way:

file_put_contents($_SERVER["DOCUMENT_ROOT"].'/files/csv.csv',  
  file_get_contents('http://site.ru/files/input.csv')
);
// Перевод в .xlsx
$objReader = PHPExcel_IOFactory::createReader('CSV')
    ->setDelimiter(";");
$csv = $objReader->load($_SERVER["DOCUMENT_ROOT"].'/files/csv.csv');
$writer= PHPExcel_IOFactory::createWriter($csv, 'Excel2007');
$writer->save($_SERVER["DOCUMENT_ROOT"]."/files/result.xlsx");

The desired result.xlsx file is created perfectly and at first glance everything is fine.
However, the next step is to process this file with the help of SpreadsheetReader
. And now it does not accept this file.
If you download the resulting result.xlsx and open it in Excel (then save it), and upload it back, then everything is fine. Apparently, when generating, some "headers" are missing and the file is "not complete".
Do not prompt with what can be connected?
Thanks to.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2018-03-20
@thisuser

first check the work on a 100% valid csv
maybe you have special characters in your csv maybe the columns break somewhere, maybe the encoding is wrong

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question