[Program] Lire xls avec PHP
Comme la plupart de mon poste même ce ne vient pas seulement avec l'intention de faire un peu de «l'information, pour me rappeler comment j'ai résolu un problème qui s'est produit pour moi: en fait, ma mémoire est généralement fallacieux et googol Pour trouver les mêmes informations plus d'une fois, je n'aime pas beaucoup ^ _ ^
Une activité qui, souvent, nous avons à faire est de traiter «à la volée" un fichier xls (peut-être en raison dell'upload disposition de l'utilisateur) et de gérer les données qu'il contient (peut-être structurée comme nous nous attendions à autre chose est la .. pas pratique), par exemple, les tableaux populaire dans une base de données ou simplement les afficher sur notre site.
Eh bien, la solution à ce problème est plus facile que vous le pensez.
Elle gère un projet sur Sourceforge qui le rend disponible via le tout classe ExcelReader nous avons besoin.
Après avoir inscrit les deux reader.php fichiers et oleread.inc dans notre script et nous serons prêts à faire le travail "sale".
Nous avons d'abord initialiser notre classe puis passiamogli le fichier à ouvrir:
$ Data-> read ( 'nome_filel.xls'); La prochaine chose à faire, bien sûr, est de faire une boucle pour chaque ligne et colonne en soulignant que:
$ Data-> sheets [0] [ 'numRows']; $ Data-> sheets [0] [ 'numCols'];
représentent le nombre de lignes et de colonnes dans le fichier xls (en particulier dans la première feuille de papier).
À ce point, on peut prendre la valeur contenue dans chaque cellule de l'accès comme nous le faisons avec une matrice triviale:
$ Data-> sheets [0] [ 'cellules'] [$ i] [$ j]; Un exemple de script pour afficher une des données vidéo à partir d'un fichier xls sous forme de tableau sont les suivantes:
<? require_once 'Excel / reader.php'; $ Data = new Spreadsheet_Excel_Reader (); $ Data-> setOutputEncoding ( 'CP1251'); $ Data-> read ( 'nome_file.xls'); error_reporting (E_ALL ^ E_NOTICE); echo "<table>"; for ($ i = 1, $ i <= $ data-> sheets [0] [ 'numRows'], $ i + +) ( echo "<tr>"; for ($ j = 1, $ j <= $ data-> sheets [0] [ 'numCols'], $ j + +) ( echo "<td>. $ data-> sheets [0] [ 'cellules'] [$ i] [$ j ]."</ td>"; ) echo "</ tr>"; ) echo "</ table>"; ?>
PS: Bien sûr vous pouvez aussi en boucle sur les feuilles qui composent le fichier xls ..
Popularité: 8% [?]
Tags: Excel, Aide FAQ et Tutorials, Source ouverte, php, SourceForge.net
leave a response , or trackback from your own site. Vous pouvez suivre les réponses à ce bulletin avec le 2.0 feed RSS. Vous pouvez laisser une réponse, ou un trackback depuis votre propre site.



![Reblog ce poste [de Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=1a581053-a80a-4f72-acd1-fdf59ecf4c5a)
![Ajoutez '[programme] Lire fichier xls avec PHP' to Del.icio.us Aggiungi '[Programmazione] Leggere file xls con PHP' a Del.icio.us](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/delicious.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' to digg Aggiungi '[Programmazione] Leggere file xls con PHP' a digg](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/digg.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' to FURL Aggiungi '[Programmazione] Leggere file xls con PHP' a FURL](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/furl.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' to blinklist Aggiungi '[Programmazione] Leggere file xls con PHP' a blinklist](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/blinklist.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' to reddit Aggiungi '[Programmazione] Leggere file xls con PHP' a reddit](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/reddit.png)
![Ajoutez '[programme] Lire fichier xls avec PHP' to Feed Me Links Aggiungi '[Programmazione] Leggere file xls con PHP' a Feed Me Links](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/feedmelinks.png)
![Ajoutez '[Programmation] Lire fichier xls avec PHP' to Technorati Aggiungi '[Programmazione] Leggere file xls con PHP' a Technorati](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/technorati.png)
![Ajoutez '[programme] Lire fichier xls avec Web PHP' a Yahoo My Aggiungi '[Programmazione] Leggere file xls con PHP' a Yahoo My Web](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' to Socializer Aggiungi '[Programmazione] Leggere file xls con PHP' a Socializer](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/socializer.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' to Ma.gnolia Aggiungi '[Programmazione] Leggere file xls con PHP' a Ma.gnolia](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/magnolia.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' to Google Bookmarks Aggiungi '[Programmazione] Leggere file xls con PHP' a Google Bookmarks](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/google.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' to Bloglines Aggiungi '[Programmazione] Leggere file xls con PHP' a Bloglines](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/bloglines.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' to Squidoo Aggiungi '[Programmazione] Leggere file xls con PHP' a OKnotizie](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/oknotizie.gif)
![Ajoutez '[programme] xls Lire fichier avec PHP' à Bookmark.it Aggiungi '[Programmazione] Leggere file xls con PHP' a Bookmark.it](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/bookmark.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' to Ask Aggiungi '[Programmazione] Leggere file xls con PHP' a Ask](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/ask.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' à Delirious Aggiungi '[Programmazione] Leggere file xls con PHP' a Delirious](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/delirious.png)
![Ajoutez '[programme] Lire fichier xls avec PHP' to Live-MSN Aggiungi '[Programmazione] Leggere file xls con PHP' a Live-MSN](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/live.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' à SlashDot Aggiungi '[Programmazione] Leggere file xls con PHP' a SlashDot](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/slashdot.png)
![Ajoutez '[Programmation] xls Lire fichier avec PHP' à Diggita Aggiungi '[Programmazione] Leggere file xls con PHP' a Diggita](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/diggita.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' to FaceBook Aggiungi '[Programmazione] Leggere file xls con PHP' a FaceBook](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/facebook.png)
![Ajoutez '[Programmation] xls Lire fichier avec PHP' à Wikio Aggiungi '[Programmazione] Leggere file xls con PHP' a Wikio](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/wikio.png)
![Ajoutez '[Programmation] xls Lire fichier avec PHP' à MySpace Aggiungi '[Programmazione] Leggere file xls con PHP' a MySpace](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/myspace.png)
![Ajoutez '[programme] xls Lire fichier avec PHP' à Twitter Aggiungi '[Programmazione] Leggere file xls con PHP' a Twitter](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/twitter.png)
![Ajoutez '[Programmation] xls Lire fichier avec PHP' to Tailrank Aggiungi '[Programmazione] Leggere file xls con PHP' a Technotizie](http://www.vitruviantux.net/wp-content/plugins/social-bookmarking-reloaded/technotizie.png)
Laissez une réponse