Posted By

stavelin on 10/08/08


Tagged

php tables excel


Versions (?)

Who likes this?

33 people have marked this snippet as a favorite

brent-man
luman
wizard04
not_skeletor
garretjames
oli
scottwf
Anber
Jdub7
nb109
Hollow
vali29
Pixelpower
kaartz
joethermal
all3n
bhu1st
kijan
bobbym245
stamba
uilgenstein
mecha
mfigge
lfcortes
prit
hypertext03
1983ron
jondiscipulo
NeekGerd
Briantjuh
tmh27
ringo380
tux-world


Easy Excel export from PHP


 / Published in: PHP
 

URL: http://www.gersh.no/posts/view/easy-excel-export-from-php

This is saved from Gerhard Slettens weblog www.gersh.no. I just want yo keep it on snipplr so it easily can be fetched through textmate.

  1. <?php
  2. header("Expires: 0");
  3. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  4. header("Cache-Control: no-store, no-cache, must-revalidate");
  5. header("Cache-Control: post-check=0, pre-check=0", false);
  6. header("Pragma: no-cache");
  7. header("Content-type: application/vnd.ms-excel;charset:UTF-8");
  8. header("Content-Disposition: attachment; filename=filename.xls");
  9. print "\n"; // Add a line, unless excel error..
  10. ?>
  11. <table border="1">
  12. <tr>
  13. <th>header 1</th>
  14. <th>header 2</th>
  15. </tr>
  16. <tr>
  17. <td>data 1</td>
  18. <td>data 2 - nordic letters æ, æ, å</td>
  19. </tr>
  20. </table>

Report this snippet  

You need to login to post a comment.