Excel sheet shows admin template . how to exclude admin template in excel sheet ?
public function export($filename = 'export.xlsx') {
$sch_id = $_GET['id'];
ob_end_clean();
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Accept-Ranges: bytes');
header('Content-Disposition: attachment; filename=' . basename($filename) . ';');
header('Content-Type: text/plain; ' . _ISO);
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Pragma: no-cache');
$sql_query = 'SELECT
cat.title,sch.*
FROM
jbt7r_scholarships_ AS sch
LEFT JOIN
jbt7r_categories AS cat ON cat.id = sch.category
WHERE
sch.id = ' . $sch_id;
$database = & JFactory::getDBO();
$csv_save = '';
$database->setQuery($sql_query);
$rows = @$database->loadAssocList();
$table = '';
$table .='<table><tr><th>Scholarship Name</th><th>Expire Date</th><th>Category Name</th><th>Description</th></tr>';
foreach ($rows as $row) {
$table .= "<tr>";
$table .= "<td>" . $row['name'] . "</td>";
$table .= "<td>" . $row['expiredate'] . "</td>";
$table .= "<td>" . $row['title'] . "</td>";
$table .= "<td>" . $row['description'] . "</td>";
$table .= "</tr>";
}
$table .= '</table>';
echo $table;
}
JFactory::getApplication()->close();
You should also take a look at following question: stackoverflow