Bonjour,

Je dois faire un export excel. J'ai opté pour la solution simple. Faire un tableau en HTML puis envoyer le header pour export en XLS.

Mon problème se pose sur des données contenant des accents : cela fonctionne à merveilles sur mon Mac mais dès que je l'utilise sur le serveur (du taff) les accents sortent pas sur le fichier excel.

Comment faire pour que cela fonctionne partout ?
Je sais il me suffit de faire utf8_decode mais dans ce cas sur mon mac cela ne passera pas.


Voilà ce que j'ai fait :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
echo "<table cellspacing='4' cellpadding='4' border=1 align=center>";
echo "<tr>";
	foreach($ligne[0] as $key => $v) {
		if(in_array($v, $selectExport)) {
			echo "<th>".$v."</th>";
			$tabIndAff[] = $key;
		}
	}
echo "</tr>";
 
$k = count($ligne[0]);
 
for ($i=1; $i < count($ligne); $i++) {
	echo "<tr valign='middle'>";
	for ($j=0; $j < $k; $j++) {
		if(in_array($j, $tabIndAff)) {
			echo "<td valign='middle' style='vertical-align:middle;'>".$ligne[$i][$j]."</td>";
		}
	}
	echo "</tr>";
}
 
echo "</table>";
 
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$nameFile.'.xls');
header('Content-Transfer-Encoding: binary');
header('Expires:0');
header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
header('Content-Type: application/force-download');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header("Cache-Control: private",false);
J'ai essayé en mettant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><meta http-equiv="X-UA-Compatible" content="IE=8" /><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /></head>';
avant la balise table mais rien....

Merci de votre aide.

Cordialement,