How to specify the correct format for reading Excel?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
27 views
Good time of day. Did export from dB to Excel using PHPExcel forces. When you open the downloaded excel file displays the error "unable to open file' ... ' because the format or extension of the file is invalid. Make sure that the file is not corrupted and the file name extension matches its format"
Here is the code for the processing and recording in excel format
$phpExcel = new PHPExcel(); $result = mysqli_query($connect, "SELECT * FROM `test_excel`"); $row = 4; while ($data = mysqli_fetch_object($result)) { $phpExcel->getActiveSheet() ->setCellValue('A'.$row , $data->id) ->setCellValue('B'.$row , $data->name) ->setCellValue('C'.$row , $data->nameScore) ->setCellValue('D'.$row , $data->noSpaceName); $row++; } header('Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition:attachment;filename="test.xlsx"'); header('Cache-Control:max-age=0'); $file = PHPExcel_IOFactory::createWriter($phpExcel, 'Excel2007'); $file->save('php://output');

I have excel 2013, if you change the line
$file = PHPExcel_IOFactory::createWriter($phpExcel, 'Excel2007');
$file = PHPExcel_IOFactory::createWriter($phpExcel, 'Excel2013');
then displays "can't open file' ... ' because the format or extension of the file is invalid."
by | 27 views

2 Answers

0 like 0 dislike
1) PHPExel of deprecated
2) Where did you get Excel2013? possible formats Exel2007 and Exel5
3) Well, in the case, or change the extension to xls or format on Exel5, it should work.
by
0 like 0 dislike
For simple formatting, it is better to use
\ropensource.box.com/spout/getting-started/#writer
sample output in browser is commented out
by

Related questions

0 like 0 dislike
2 answers
asked Jun 13, 2019 by Leocoan
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
110,608 questions
257,187 answers
0 comments
40,796 users