i need a way to export data on the php form to excel on a click . how can i do this

Recommended Answers

All 2 Replies

Hi 16pradeepkumar and welcome to DaniWeb :)

Do you need to specifically export to xls file format? The reason I ask is that it is not a trivial task to do this, whereas export to cvs is simple and you can open a cvs file in Microsoft Excel.

thanks for the suggestion , i could solve this by using a piece of code i got , now am able to export the data to excel . the code is as follows

<?php
$filename ="excelreport.xls";
$contents = "testdata1 \t testdata2 \t testdata3 \t \n";
header('Content-type: application/ms-excel');
header('Content-Disposition: attachment; filename='.$filename);
echo $contents;
?>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.