I have an action that returns an Excel file. Accessing this route in a browser will automatically download my Excel file.
I wrote a test for this action, but all I can say is the data from the headers. In addition, the test displays the answer directly to the console with the text type w֑m J 9 9 e 줽o .
Is there a way to make statements about the data that comes from this excel file? The file is not saved, only the content is displayed in response. I am using Symfony2.
EDIT
I found a way to read this data by storing the response in the output buffer, storing the contents in a .xlsx file, converting to a CSV file, and retrieving the contents from there.
ob_start();
$this->client->request(
'GET',
'/myUrl',
array(),
array(),
array()
);
$content = ob_get_clean();
file_put_contents('MyFile.xlsx', $content);
$reader = \PHPExcel_IOFactory::createReader('Excel2007');
$excel = $reader->load('MyFile.xlsx');
$writer = \PHPExcel_IOFactory::createWriter($excel, 'CSV');
$writer->save('MyFileCsv.csv');
$newContent = fgetcsv(fopen("MyFileCsv.csv", "r"));
. , , , .
, .