how to insert anchor tag in export csv report php? -


i want insert anchor tag ( url open csv report ) in csv export.

i have 2 variables header , data respectively $csv_header , $csv_lines.

in $csv_lines have urls , want export it.

my csv code

$csv_header = "\"developer name\",\"url\" \n";  $csv_lines =eregi_replace(" ", " ", "\"$developer_name\",\"$url\" \n"); 

for example $url = <a href="http://www.example.com">example</a>

$file_time = date("y-m-d h:i:s"); $csvfilename = "report_$us$file_time.csv";         header('content-type: application/octet-stream');         header("content-disposition: attachment; filename=\"$csvfilename\"");         header('expires: 0');         header('cache-control: must-revalidate, post-check=0, pre-check=0');         header('pragma: public');         ob_clean();         flush();         echo $csv_header;         echo $csv_lines ; 

there few points consider..

  1. csv plain text, , doesn't support type of format.

  2. you shouldn't try write own csv. use fputcsv() if your'e still going continue working csv format.

  3. you can use xls builder or equivalent whichever software you're looking open in.

  4. you can use .xls extension , output normal html table , spreadsheet software shall handle gracefully.


<?php $csv_lines      = "<table border=1>         <tr>           <td>1</td>           <td>developer name</td>           <td><a href='http://www.example.com'>example</a></td>         </tr>       </table>"; $file_time = date("y-m-d h:i:s"); $csvfilename = "report_$us$file_time.xls";         header('content-type: application/octet-stream');         header("content-disposition: attachment; filename=\"$csvfilename\"");         header('expires: 0');         header('cache-control: must-revalidate, post-check=0, pre-check=0');         header('pragma: public');         ob_clean();         flush();         echo $csv_lines ; ?> 

phpfiddle


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -