Answers for "php export to excel"

PHP
0

export to excel in php

$queryexport = ("
SELECT username,password,fullname FROM ecustomer_users
WHERE fk_customer='".$fk_customer."'
");

$row = mysql_fetch_assoc($queryexport);

$result = mysql_query($queryexport);
$header = '';

for ($i = 0; $i < $count; $i++){
   $header .= mysql_field_name($result, $i)."t";
   }

while($row = mysql_fetch_row($result)){
   $line = '';
   foreach($row as $value){
          if(!isset($value) || $value == ""){
                 $value = "t";
          }else{
                 $value = str_replace('"', '""', $value);
                 $value = '"' . $value . '"' . "t";
                 }
          $line .= $value;
          }
   $data .= trim($line)."n";
   $data = str_replace("r", "", $data);

if ($data == "") {
   $data = "nno matching records foundn";
   }
}
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: attachment; filename=exportfile.xls");
header("Pragma: no-cache");
header("Expires: 0");

// output data
echo $header."n".$data;

mysql_close($conn);`
Posted by: Guest on February-22-2022
-2

export html table data to excel in php

Use a PHP Excel for generatingExcel file. You can find a good one called PHPExcel here: https://github.com/PHPOffice/PHPExcel

And for PDF generation use http://princexml.com/
Posted by: Guest on March-05-2021

Browse Popular Code Answers by Language