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>
21 var $_file_type_codes = array('csv' => 6,'msdos' => 21,'xls'=>-4143,'rtf'=>6,'unicode'=>7,'doc'=>0,'html'=>8,'txt'=>4);
25 $excel = new COM('excel.application') or die('Unable to instantiate Excel');
26 $excel->Visible
= false;
27 $excel->WorkBooks
->Open($this->source_file
);
28 $excel->WorkBooks
[1]->SaveAs($this->destination_file
,$this->_file_type_codes
[$this->convert_to
]);
32 $result = Ak
::file_get_contents($this->destination_file
);
33 $this->delete_source_file ? @Ak
::file_delete($this->source_file
) : null;
34 $this->keep_destination_file ?
null : Ak
::file_delete($this->destination_file
);
41 $this->ext
= empty($this->ext
) ?
'xls' : strtolower(trim($this->ext
,'.'));
42 $this->tmp_name
= Ak
::randomString();
43 if(empty($this->source_file
)){
44 $this->source_file
= AK_TMP_DIR
.DS
.$this->tmp_name
.'.'.$this->ext
;
45 Ak
::file_put_contents($this->source_file
,$this->source
);
46 $this->delete_source_file
= true;
47 $this->keep_destination_file
= empty($this->keep_destination_file
) ?
(empty($this->destination_file
) ?
false : true) : $this->keep_destination_file
;
49 $this->delete_source_file
= false;
50 $this->keep_destination_file
= true;
53 $this->convert_to
= !empty($this->convert_to
) && empty($this->_file_type_codes
[$this->convert_to
]) ?
'csv' : (empty($this->convert_to
) ?
'csv' : $this->convert_to
);
54 $this->destination_file_name
= empty($this->destination_file_name
) ?
$this->tmp_name
.'.'.$this->convert_to
: $this->destination_file_name
.(strstr($this->destination_file_name
,'.') ?
'' : '.'.$this->convert_to
);
55 $this->destination_file
= empty($this->destination_file
) ? AK_TMP_DIR
.DS
.$this->destination_file_name
: $this->destination_file
;