This topic is locked

Create reports with phpSpreadsheet (updated 07/24/2024)

7/24/2024 3:26:46 PM
PHPRunner Tips and Tricks
fhumanes author

img alt

In this update, an attempt has been made to improve security and the information provided to the user to indicate that the report is being prepared.

Specifically, a progress graph has been placed to indicate that the report is being prepared or downloaded.

img alt

The 3rd state button is coded:

  • Client (Before):

Swal.fire({
// icon: 'info',
title: 'El Informe se ha inciado y se está ejecutando',
text: '',
imageUrl: "MyCode/images/calculated.gif",
imageHeight: 200,
imageAlt: "Estamos trabajando",
timer: 60000,
timerProgressBar: true,
toast: true,
showConfirmButton: false,
position: 'center', // "top-start",
footer: ''
})
  • Server:

$_SESSION['report_fase'] = 1;
$_SESSION['report_file'] = '';

include "MyCode/Report001/report.php";

$_SESSION['report_fase'] = 2;
$result['report_file'] = $_SESSION['report_file']
  • Client (After):

window.open("MyCode/Report001/report.php","_blank" );

Swal.fire({
// icon: 'info',
title: 'El Informe se ha descargado',
text: '',
imageUrl: "MyCode/images/download.gif",
imageHeight: 200,
imageAlt: "Estamos trabajando",
timer: 4000,
timerProgressBar: true,
toast: true,
showConfirmButton: false,
position: 'center', // "top-start",
footer: ''
})

With this system, the report preparation process is divided into 2 phases ( obtaining and downloading ). At a security level, the report cannot be executed even if the URL of the report is known and the user is provided with the graph indicating that the report is being prepared.

DEMO: https://fhumanes.com/reports/

If you are interested in this topic or want to have the example, follow this link .

C
cristi 7/25/2024

Great tutorial as ever Fernando - your contribution to the community means a lot.
One suggestion if I may: sweetalert 2 has native support for showing a loading window animation with message and buttons disabled so you don't need to upload a custom animation, disable buttons:

Swal.fire({
title: 'Exporting file....',
icon: 'info',
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false,
didOpen: function () {
Swal.showLoading()
//you can put here an AJAX request simulated with setTimeout or what you want...
}
})
}
fhumanes author 7/25/2024

Thank you very much @cristi
Always so pleasant and generous.
Greetings,
fernando

J
Josedomer 9/17/2024

Hola fhumanes, me gustan muchos tus articulos, los tienes en español?? Gracias

fhumanes author 9/19/2024

Hola @Josedomer,

Todos mis artículos que puedas ver publicados aquí están en mi blog, en español y con traducción por Google, a otros muchos idiomas.

All my articles that you can see published here are in my blog, in Spanish and with translation by Google, to many other languages.

https://fhumanes.com/blog/

Regards / Saludos,
fernando