Export CSV file Drupal


  // send response headers to the browser
  drupal_add_http_header('Content-Type', 'text/csv');
  drupal_add_http_header('Content-Disposition', 'attachment;filename=csvfile.csv');

  $csv_array = array(
    array('one', 'two', 'three'),
    array('1', '2', '3'),

  $fp = fopen('php://output', 'w');
  foreach($csv_array as $line){
    fputcsv($fp, $line);

One thought on “Export CSV file Drupal

  1. Write more, thats all I have to say. Literally, it seems as
    though you relied on the video to make your point. You obviously know what youree talking about, why
    waste your intelligence on just posting videos to your
    site when you could be giving uss something enlightening to read?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s