I'm trying to make a functionality that exports a part of my database as readable excel file. Everything works fine but every time I open the downloaded file I keep getting the following error:
The file format and extension of [filename] don't match. The file could be corrupted or unsafe. Unless you trust its source, don't open it. Do you want to open it anyway?
the code:
//Get site location
$siteLocation = Db::getInstance()->queryResults('SELECT place FROM site WHERE site_number=?', array($siteNumber));
// The function header by sending raw excel
header("Content-type: application/vnd-ms-excel");
$documentName = 'Content-Disposition: attachment; filename='. $siteNumber . ' ' . $siteLocation[0]->place .'.xls';
// Defines the name of the export file (siteNumber + site Location)
header($documentName);
// Add data table
include 'exceldata.php';
How can I fix these trust issues Excel has on my compiled excel files?
Ps. when clicking 'yes' the file opens fine and I don't get the same message with other excelfiles.
Thanks in advance!