tags:

views:

43

answers:

1

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.

+1  A: 

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?

Anti Veeranna
yes this is what i am asking. But am asking is there any difference in format or anything internally to thefile genrated by two ways or they will be identical?
zod
No. The code you provided in the question does not affect the data that you are creating - the difference is merely in how you serve the data. If you are getting different results, then the bug is elsewhere - in the code you are not showing.
Anti Veeranna