One Way
am creating an xls with fopen(“test.xls”) .
Using fwrite i write xls and readfile give me the file.
Second Way
I generating xls with putting
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header ("Pragma: no-cache");
header("Expires: 0");
header('Content-Transfer-Encoding: none');
header("Content-Disposition: attachment; filename=\"test.xls\"");
header("Content-Type: application/vnd.ms-excel");
foreach ()
{
echo contents to the file
}
Is there any difference between these 2 ways of generating file.
What is difference.
Your first approach creates the file inside the server filesystem, then serves it through the browser. The file stays there (unless you have extra code to delete it afterwards).
Your second approach does not seem to create an actual file inside the filesystem, it generates data on the fly – and the browser then saves it to a file.
Is that what you were asking?