dolibarr  9.0.0
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 {
39  public $id;
40 
44  public $label;
45 
46  public $extension;
47 
52  public $version = 'dolibarr';
53 
54  public $label_lib;
55 
56  public $version_lib;
57 
58  public $workbook; // Handle fichier
59 
60  public $worksheet; // Handle onglet
61 
62  public $row;
63 
64  public $col;
65 
66  public $file; // To save filename
67 
73  function __construct($db)
74  {
75  global $conf, $langs;
76  $this->db = $db;
77 
78  $this->id='excel2007'; // Same value then xxx in file name export_xxx.modules.php
79  $this->label='Excel 2007'; // Label of driver
80  $this->desc = $langs->trans('Excel2007FormatDesc');
81  $this->extension='xlsx'; // Extension for generated file by this driver
82  $this->picto='mime/xls'; // Picto
83  $this->version='1.30'; // Driver version
84 
85  $this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages)
86 
87  if (empty($this->disabled))
88  {
89  // If driver use an external library, put its name here
90  if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
91  {
92  require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
93  require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
94  require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
95  $this->label_lib='PhpWriteExcel';
96  $this->version_lib='unknown';
97  }
98  else
99  {
100  require_once PHPEXCEL_PATH.'PHPExcel.php';
101  require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
102  $this->label_lib='PhpExcel';
103  $this->version_lib='1.8.0'; // No way to get info from library
104  }
105  }
106 
107  $this->row=0;
108  }
109 
110 
111  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
117  function close_file()
118  {
119  // phpcs:enable
120  global $conf;
121 
122  if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
123  {
124  $this->workbook->close();
125  }
126  else
127  {
128  require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
129  $objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
130  $objWriter->save($this->file);
131  $this->workbook->disconnectWorksheets();
132  unset($this->workbook);
133  }
134  return 1;
135  }
136 }
print $object label
hash of file content (md5_file(dol_osencode($destfull))
Definition: edit.php:153
$version
Dolibarr version of the loaded document string.
Class to build export files with Excel format.
Class to build export files with Excel format.
close_file()
Close Excel file.
__construct($db)
Constructor.