1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
<?php
set_time_limit(1000);
require_once "php_writeexcel-0.3.0/class.writeexcel_workbook.inc.php";
require_once "php_writeexcel-0.3.0/class.writeexcel_worksheet.inc.php";
require_once ("../config.php");
$fname = tempnam("/tmp", "invitation.xls");
$workbook = &new writeexcel_workbook($fname);
$worksheet =& $workbook->addworksheet();
# Set the column width for columns 1, 2, 3 and 4
$worksheet->set_column(0, 3, 15);
# Create a format for the column headings
$header =& $workbook->addformat();
$header->set_bold();
# Create a format for the stock volume
$f_tel =& $workbook->addformat();
$f_tel->set_align('left');
$f_tel->set_num_format('0#########');
# Write out the data
$worksheet->write(0, 0, 'Nom', $header);
$worksheet->write(0, 1, 'Entreprise', $header);
$worksheet->write(0, 2, 'Adresse', $header);
$worksheet->write(0, 3, 'Telephone', $header);
$worksheet->write(0, 4, 'Email', $header);
$worksheet->write(0, 5, 'Metier/Activite', $header);
$worksheet->write(0, 6, 'Apres-Midi', $header);
$worksheet->write(0, 7, 'Cocktail', $header);
$bdd = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_NAME, $bdd);
$dbres = mysql_query("SELECT * FROM inauguration ORDER BY id", $bdd);
$ligne = 1;
while($row = mysql_fetch_assoc($dbres)) {
$worksheet->write($ligne, 0, $row["sexe"]." ".$row["nom"]." ".$row["prenom"]);
$worksheet->write($ligne, 1, $row["entreprise"]);
$worksheet->write($ligne, 2, $row["rue"]." ".$row["cp"]." ".$row["ville"]);
$worksheet->write($ligne, 3, $row["telephone"], $f_tel);
$worksheet->write($ligne, 4, $row["mail"]);
$worksheet->write($ligne, 5, $row["activite"]);
$worksheet->write($ligne, 6, $row["apresMidi"]);
$worksheet->write($ligne, 7, $row["cocktail"]);
$ligne++;
}
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"invitation.xls\"");
header("Content-Disposition: inline; filename=\"invitation.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
?> |
Partager