Bonjour à tous!
Je veux crée un fichier excel qui va contient les résultats du traitement php:
voila mon code :
Le problème c'est que je veux remplir les lignes du fichier excel d'une manier dynamique ici les résultats statique !!
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
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168 <?php include $_SERVER['DOCUMENT_ROOT'] . '/phpexcel/Classes/PHPExcel.php'; // include PHPExcel.php include $_SERVER['DOCUMENT_ROOT'] . '/phpexcel/Classes/PHPExcel/Writer/Excel2007.php';// include PHPExcel/Writer/Excel2007.php ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1256" /> <LINK rel="stylesheet" type="text/css" href="style/style.css"> <title>Résumer du texte</title> </head> <body> <table width="100%" height="100%" border="0"> <tbody><tr align="center"> <td height="90" colspan="3" bgcolor="#000000"><img src="image/resumeur.png" width="352" height="69"></td> </tr> <tr> <form action="" method="post"> <td width="16%"> </td> <td width="66%" align="center"> <strong>Saisissez/collez le texte à résumer dans le champs si dessous puis </strong> <input type="submit" name="validez" value="Validez"> <br> <textarea name="resumer" rows="15" cols="110"><?php if (isset($_POST['resumer'])) echo $_POST['resumer'] ; ?> </textarea> <br> <input name="ok" type="submit" value="Valider"> </td> <td width="18%" align="center"><table width="100%" border="0"> <tbody><tr> <td align="center"><font size="1"><a href="www.3wmedia.ma">-aide-</a></font></td> </tr> <tr> <td> </td> </tr> </tbody></table> <table width="100%" border="0"> <tbody><tr> <td align="center" bgcolor="#000000"><strong><font color="#FFFFFF">Options</font></strong></td> </tr> <tr> <td><select name="langue"> <option value="en">Arabe</option> <option value="fr">Français</option> <option value="en">English</option> </select> Langue </td> </tr> <tr> <td><select name="compress"> <option value="30">30%</option> <option value="10">10%</option> <option value="20">20%</option> <option value="30">30%</option> <option value="40">40%</option> <option value="50">50%</option> <option value="60">60%</option> <option value="70">70%</option> </select> Compression</td> </tr> <tr> <td> <input name="html" type="checkbox" value="checked"> afficher la source</td> </tr> </tbody></table></td> </form> </tr> <tr> <td height="91"> </td> <td valign="top"> <table width="80%" border="1" align="center" cellspacing="0" bordercolor="#000000"> <tbody><tr> <td align="center" bgcolor="#000000"><font color="#FFFFFF"><strong>Résumé</strong></font></td> </tr> <tr> <td> <p align="center"><font color='#000000' face="Trebuchet MS" size="3"><strong>Sujet :</strong></font> <?php $chaine=""; if (isset($_POST['resumer'])){ $chaine=$_POST['resumer']; $sujet= substr($chaine, 0, 20); echo "<b>$sujet</b>"; echo "<br/><div class=\"stl_chaine\"> $chaine</div>"; } ?></p> <p align="center"><strong><font size="2"> <?php // Longueurs de chaînes $longueur = strlen($chaine); $count_word = str_word_count($chaine); //affichage de la Longueur du chaîne echo "<br /><br /><font color='#000938' face='arial' size='2'>Votre texte contient</font> <font color='#B9121B' face='verdana' size='2'>$longueur </font> <font color='#000938' face='arial' size='2'>caractères.</font><br />"; echo "<font color='#000938' face='arial' size='2'>Votre texte contient</font> <font color='#B9121B' face='verdana' size='2'>$count_word </font> <font color='#000938' face='arial' size='2'>Mots.</font><br /><br /><br />"; // teste des occurences dans un texte données $tab = str_word_count($chaine, 2); $occ = array(); foreach ($tab as $word) { if (!isset($occ[$word])) $occ[$word] = 0; $occ[$word]++; } //******** fin teste *************************** ?> </font></strong></p> <br> <table width="450" border="0" align="center"> <tr bgcolor="#324800" height="30px"> <td align="center"><b><font color='#F8FAF4' face="arial" size="2">Mots</font></b></td> <td align="center"><b><font color="#F8FAF4" face="arial" size="2">Nombre d'occurence</font></b></td> </tr> <?php // affichage de données sous forme un tableau foreach($occ as $cle=>$valeur) { echo "<tr> <td bgcolor='#90CE00' ><b><font color='#000938' face='arial' size='2'>$cle</font></b></td> <td bgcolor='#DFFAA0' align='center'><b><font color='#000938' face='arial' size='2'>$valeur</font></b></td> </tr>"; } ?> </table></td> </tr> </tbody></table> <br> </td> <td> </td> </tr> <tr align="center" valign="bottom" bgcolor="#000000"> <td height="90" colspan="3"><font color="#FFFFFF" size="1">Copyright © 2013, 3wmedia.ma -<a href="http://3wmedia.ma"> <font color="#FFFFFF">informations légales </font></a></font></td> </tr> </tbody></table> <?php // Création de fichier excel qui doit contient les résultats mais ici les résultats statique $workbook = new PHPExcel; $sheet =$workbook->getActiveSheet(); $sheet->setCellValue('A1','Mots');// colon A line 1 contient la chaine mots c'est bien $sheet->setCellValue('B1','Nombre occurence');// colon B line 1 contient la chaine Nombre occurence aussi c'est bien $sheet->setCellValue('A2', $cle); // ici le probleme je veux affichier ici les mots d'une manier dynamique $sheet->setCellValue('B2', $valeur);// les resultats numurique aussi d'une manier dynamique je sais pas comment le faire?? $writer = new PHPExcel_Writer_Excel2007($workbook); $records = './fichier.xlsx'; $writer->save($records); ?> </body> </html>
Merci de me donnée le bon chemin à suivre ...
Partager