2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4 // +----------------------------------------------------------------------+
5 // | Akelos Framework - http://www.akelos.org |
6 // +----------------------------------------------------------------------+
7 // | Copyright (c) 2002-2006, Akelos Media, S.L. & Bermi Ferrer Martinez |
8 // | Released under the GNU Lesser General Public License, see LICENSE.txt|
9 // +----------------------------------------------------------------------+
12 * @package ActiveSupport
13 * @subpackage Converters
14 * @author Bermi Ferrer <bermi a.t akelos c.om>
15 * @copyright Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
16 * @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html>
23 $this->handler
->read($this->source_file
);
26 for ($i = 1; $i <= $this->handler
->sheets
[0]['numRows']; $i++
) {
28 @$col_names = $this->handler
->sheets
[0]['cells'][$i-1];
29 foreach (range(1, $this->handler
->sheets
[0]['numCols']) as $column_number){
30 $col_names[$column_number-1] = empty($col_names[$column_number-1]) ?
$column_number : trim($col_names[$column_number-1],"\t\n\r ");
35 for ($j = 0; $j < $this->handler
->sheets
[0]['numCols']; $j++
) {
36 $result[$i-2][$col_names[$j]] = isset($this->handler
->sheets
[0]['cells'][$i-1][$j]) ?
$this->handler
->sheets
[0]['cells'][$i-1][$j] : null;
39 $this->delete_source_file ? @Ak
::file_delete($this->source_file
) : null;
45 if(empty($this->handler
)){
46 require_once(AK_VENDOR_DIR
.DS
.'Excel'.DS
.'reader.php');
47 $this->handler
= new Spreadsheet_Excel_Reader();
48 $this->handler
->setRowColOffset((empty($this->first_column
) ?
0 : $this->first_column
));
51 $this->tmp_name
= Ak
::randomString();
52 if(empty($this->source_file
)){
53 $this->source_file
= AK_TMP_DIR
.DS
.$this->tmp_name
.'.xls';
54 Ak
::file_put_contents($this->source_file
,$this->source
);
55 $this->delete_source_file
= true;
56 $this->keep_destination_file
= empty($this->keep_destination_file
) ?
(empty($this->destination_file
) ?
false : true) : $this->keep_destination_file
;
58 $this->delete_source_file
= false;
59 $this->keep_destination_file
= true;