public function __construct($mode, $filename, $settings, $format, $labels)
 {
     parent::__construct($mode, $filename, $settings, $format, $labels);
     if ($mode != 'preview') {
         fclose($this->handle);
         $this->filename = $filename;
         if (filesize($this->filename) > 0) {
             $this->objPHPExcel = PHPExcel_IOFactory::load($this->filename);
         } else {
             $this->objPHPExcel = new PHPExcel();
         }
         $this->objPHPExcel->setActiveSheetIndex(0);
         $this->last_row = $this->objPHPExcel->getActiveSheet()->getHighestRow();
     }
 }
 public function finish()
 {
     if ($this->mode == 'preview') {
         fwrite($this->handle, '<table>');
         if (count($this->rows) < 2) {
             $this->rows[] = array(__('<td colspan=10><b>No results</b></td>', 'woocommerce-order-export'));
         }
         foreach ($this->rows as $rec) {
             $rec = array_map(function ($a) {
                 return '<td>' . $a . '';
             }, $rec);
             fwrite($this->handle, '<tr><td>' . join('</td><td>', $rec) . "</td><tr>\n");
         }
         fwrite($this->handle, '</table>');
     }
     parent::finish();
 }
 public function finish($data = '')
 {
     fwrite($this->handle, "</" . $this->settings['root_tag'] . ">\n");
     parent::finish();
 }
 public function finish($data = '')
 {
     fwrite($this->handle, "\n]");
     parent::finish();
 }