I tried the following function but there is no output
function exportgridxls($filteredParticipants = null) {
global $account, $user, $arr_filters;
require(SITE_ROOT . 'include/connector/convert.php');
$mysqli = new Db;
$config = new GridConfiguration();
$setHeader = "ID,First Name,Last Name,E-mail,Survey Link,E-mail Sent";
$setInitWidths = '50,120,150,150,200,130';
$setColAlign = "center,left,left,center,left,left";
foreach($account->userDataFields as $dataFieldId => $dataFieldName){
if($account->dataFieldsVisible[$dataFieldId]) {
$setHeader .= "," . $dataFieldName;
$setInitWidths .= ',150';
$setColAlign .= ",center";
};
};
$setHeader .= ",Status,Completed,Completion Date,Furthest Page Reached";
$setInitWidths .= ',100,150,200,250';
$setColAlign .= ",center,center,left,left";
$config->setHeader($setHeader);
//$config->setInitWidths($setInitWidths);
$config->setColAlign($setColAlign);
//grid data
$data = array();
$userParticipants = is_null($filteredParticipants) ? $account->userParticipants : $filteredParticipants;
foreach ($userParticipants as $participant_id => $participant) {
if(empty($participant->data)|| empty($participant->tagging)) $participant->getData();
$pdata = array("id" => $participant->id,"firstname" => $participant->firstName ,"lastname" => $participant->lastName ,"email" => $participant->email,"survey" => RADAR_SURVEY_LINK. 'participant/' . $participant->key);
$pdata["lastmail"] = $participant->tsLastEmail;
foreach($account->userDataFields as $dataFieldId => $dataFieldName){
if($account->dataFieldsVisible[$dataFieldId]) {
if(empty($participant->tagging) || !array_key_exists($dataFieldName,$participant->tagging)){
$pdata["$dataFieldName"] = "";
}else{
$pdata["$dataFieldName"] = $participant->tagging["$dataFieldName"];
};
};//data field
};
$pdata["completed"] = ($participant->completed == true) ? 'Completed' : 'Incomplete';
$pdata["completeddate"] = ($participant->tsComplete == 0) ? '' : date('d-m-Y h:s:i', $participant->tsComplete);
$data[] = $pdata;
};
if(count($data)){
$convert = new ConvertService(
RADAR_SURVEY_LINK . "app/ajax_participants/<?=$account->id?>/exportxl"
);
$conn = new GridConnector($mysqli, "MySQLi");
$conn->set_config($config);
$convert->excel();
$columns = implode(",",array_keys($data[0]));
$conn->render_array($data, "id", $columns);
};
}
The request to the function returned the following but no excel
Any idea what might be going wrong here ?