| 234 |
jpm |
1 |
<?php
|
|
|
2 |
require_once dirname(__FILE__).DS.'excel_reader'.DS.'excel_reader2.php';
|
|
|
3 |
|
|
|
4 |
class LecteurExcel {
|
|
|
5 |
|
|
|
6 |
private $lecteur = null;
|
|
|
7 |
private $fichier = '';
|
|
|
8 |
private $feuille = 0;
|
|
|
9 |
|
|
|
10 |
public function __construct($fichierExcel) {
|
|
|
11 |
error_reporting(E_ALL ^ E_NOTICE);
|
|
|
12 |
$this->fichier = $fichierExcel;
|
|
|
13 |
$this->lecteur = new Spreadsheet_Excel_Reader();
|
|
|
14 |
$this->lecteur->setUTFEncoder('mb');
|
|
|
15 |
$this->lecteur->setOutputEncoding('UTF-8');
|
|
|
16 |
$this->lecteur->read($this->fichier);
|
|
|
17 |
}
|
|
|
18 |
|
|
|
19 |
public function getFichier() {
|
|
|
20 |
return $this->fichier;
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
public function getFeuille() {
|
|
|
24 |
return $this->feuille;
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
public function setFeuille($feuille) {
|
|
|
28 |
return $this->feuille = $feuille;
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
public function getValeur($ligne, $colonne) {
|
|
|
32 |
$val = $this->lecteur->val($ligne, $colonne, $this->feuille);
|
|
|
33 |
return $val;
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
public function getValeurBrute($ligne, $colonne) {
|
|
|
37 |
return $this->lecteur->raw($ligne, $colonne, $this->feuille);
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
public function getNbreLignes() {
|
|
|
41 |
return $this->lecteur->rowcount($this->feuille);
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
public function getNbreColonne() {
|
|
|
45 |
return $this->lecteur->colcount($this->feuille);
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
public function getDonnees() {
|
|
|
49 |
return $this->lecteur->sheets[$this->feuille];
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
public function afficherTxt() {
|
|
|
53 |
foreach ($this->lecteur->sheets as $k => $data) {
|
|
|
54 |
echo "Fichier : {$this->fichier}.\nFeuille $k\n";
|
|
|
55 |
foreach ($data['cells'] as $idRow => $row) {
|
|
|
56 |
foreach ($row as $idCol => $cell) {
|
|
|
57 |
echo $this->getValeur($idRow, $idCol)."\t";
|
|
|
58 |
}
|
|
|
59 |
echo "\n";
|
|
|
60 |
}
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
?>
|