You can create a CSV file which Excel can import. Take this code and adapt it:
viewtopic.php?f=41&t=710430&p=790694#p790694
Here would be the adapted code:
Code: Select allif (isset(@=productsList) and is_array(@=productsList) and count(@=productsList)) {
$aCsv = array();
//set the first row in the CSV file to the IDs of the grid fields
$aColumnHeaders = array_keys(@=productsList[1]);
$line = '';
foreach ($aColumnHeaders as $fieldId) {
$line .= (empty($line) ? '' : ';') . $fieldId;
}
$aCsv[] = $line;
//set each data row in CSV file:
foreach (@=productsList as $aRow) {
$line = '';
foreach ($aColumnHeaders as $fieldId) {
$val = $aRow[$fieldId];
if (is_array($val) or is_object($val)) {
$val = json_encode($val);
}
//sanitize CSV data to handle double quotation marks, commas, semicolons,
//spaces and new lines
$val = str_replace('"', '""', $val);
if (preg_match('/[,;"\n\r]/', $val) or trim($val) != $val) {
$val = '"' . $val . '"';
}
$line .= (empty($line) ? '' : ';') . $val;
}
$aCsv[] = $line;
}
//create a temporary output file:
$path = tempnam(sys_get_temp_dir(), "products_") . ".csv";
file_put_contents($path, implode("\n", $aCsv));
$aAttachFiles = array(
"products.csv" => $path
);
$usr = userInfo(@@USER_LOGGED);
PMFSendMessage(@@APPLICATION, 'manager@acme.com', $usr['mail'], '', '',
'Company Information', 'companyInfoTemplate.html', array(), $aAttachFiles);
unlink($filename); //delete temporary CSV file
}