Close download page

Topics: Developer Forum, User Forum
May 4, 2011 at 1:12 PM

Hello, first: sorry for my english.

I have a main php page that call another php page that make an .xls and put it to download

In main page I use a js to open the another page:


        function recargarAlumnosExcelDownl(){
            cur_id = document.getElementById("listaCursos").options[document.getElementById("listaCursos").selectedIndex].value;
            al_legajo = document.getElementById("listaAlumnos").options[document.getElementById("listaAlumnos").selectedIndex].value;

the another page...

// Redirect output to a client's web browser (Excel5)
header('Content-Type: application/');
header('Content-Disposition: attachment;filename="reporte.xls"');
header('Cache-Control: max-age=0');

include_once 'Classes/PHPExcel/IOFactory.php';

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

How can I close the opened page when the download end or how can avoid open a new window to call php for download?

Thank you in advance and again: sorry for my english.



May 4, 2011 at 1:27 PM

Just include('other.php') at the end of main.php -- or just put all the other.php at the end of main.php.

You should not need JS to output the XLS.

The end user will not see the output link unless you provide it as an actual link.

May 4, 2011 at 2:17 PM
Edited May 4, 2011 at 2:25 PM

Thank you Scott, but a I need a link in main.php, If the user clicks on that link, then just call generation excel (other.php)


<input type="button" value="Excel2" name="btn_excel2" id="btn_excel2" onclick="recargarAlumnosExcelDownl();" />
May 4, 2011 at 2:31 PM

In that case, instead of, try window.location.href.