0

enter image description hereExcel 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;
}
  • Can you please be a little more specific as to what your issue is. As it stands, what you've provided is not much to go with. – Lodder Feb 19 '15 at 10:37
  • In my excel sheet admin menu displays such as menu, dashboard,global configuration etc., – vignesh.D Feb 19 '15 at 10:37
  • Which excel sheet ? Where did you get it ? – Nils Rückmann Feb 19 '15 at 10:38
  • In 'export.xlsx' .... – vignesh.D Feb 19 '15 at 10:38
  • 1
    JFactory::getApplication()->close(); You should also take a look at following question: stackoverflow – Nils Rückmann Feb 19 '15 at 10:45
1

Closing the app to prevent it from default rendering process

  JFactory::getApplication()->close();
0

if you are using the export function from a url try adding &tmpl=component in the url (check if your template has a component.php file) this file only show the main component without template or modules

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.