Smit Saraiya Smit Saraiya - 1 month ago 11
PHP Question

excel file not downloading in proper format in php

I have use following code for download excel file.

$filename = "property.xls"; // File Name
// Download file
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");


But, it will download blank excel file i need to download content of
<table>
tag.

I have place this code at top of page and during reloading of my page it will download excel file but it was empty every time.

Answer

As per last comment by @ravisachaniya i have removed <head> and <title> tag and all default content which comes when we create page, from current page and from connection page, Now it is works properly