dolibarr  7.0.0-beta
export_excel2007.modules.php
1 <?php
2 /* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2012 Marcos GarcĂ­a <marcosgdf@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
26 require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/modules/export/export_excel.modules.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
29 
30 
35 {
36  var $id;
37  var $label;
38  var $extension;
39  var $version;
40 
41  var $label_lib;
42  var $version_lib;
43 
44  var $workbook; // Handle fichier
45  var $worksheet; // Handle onglet
46  var $row;
47  var $col;
48  var $file; // To save filename
49 
55  function __construct($db)
56  {
57  global $conf, $langs;
58  $this->db = $db;
59 
60  $this->id='excel2007'; // Same value then xxx in file name export_xxx.modules.php
61  $this->label='Excel 2007'; // Label of driver
62  $this->desc = $langs->trans('Excel2007FormatDesc');
63  $this->extension='xlsx'; // Extension for generated file by this driver
64  $this->picto='mime/xls'; // Picto
65  $this->version='1.30'; // Driver version
66 
67  $this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages)
68 
69  if (empty($this->disabled))
70  {
71  // If driver use an external library, put its name here
72  if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
73  {
74  require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
75  require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
76  require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
77  $this->label_lib='PhpWriteExcel';
78  $this->version_lib='unknown';
79  }
80  else
81  {
82  require_once PHPEXCEL_PATH.'PHPExcel.php';
83  require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
84  $this->label_lib='PhpExcel';
85  $this->version_lib='1.8.0'; // No way to get info from library
86  }
87  }
88 
89  $this->row=0;
90  }
91 
92 
98  function close_file()
99  {
100  global $conf;
101 
102  if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
103  {
104  $this->workbook->close();
105  }
106  else
107  {
108  require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
109  $objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
110  $objWriter->save($this->file);
111  $this->workbook->disconnectWorksheets();
112  unset($this->workbook);
113  }
114  return 1;
115  }
116 
117 }
118 
Class to build export files with Excel format.
Class to build export files with Excel format.
close_file()
Close Excel file.
__construct($db)
Constructor.