Jump to content

Using PHP to Export Excel Sheet


sh0wtym3

Recommended Posts

Hey all,

 

I found the following code online which allows you to create and export an excel sheet using PHP:

      <?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;

      ?>

 

It works, however, there are certain problems that occur when I try to copy the cells from that php-generated excel sheet, to an excel sheet I have on my PC.

 

I have to copy the content in the cells to notepad, and then to an excel sheet on my pc for it to copy correctly.

 

I think this has to do with encoding the character set for the php generated excel sheet, but I'm not sure what to set it to or how to accomplish that - does anyone know how?

Link to comment
https://forums.phpfreaks.com/topic/195162-using-php-to-export-excel-sheet/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.