terminal42 / contao-leads

Leads extension for Contao Open Source CMS; Store and manage form data with ease!
GNU Lesser General Public License v3.0
35 stars 24 forks source link

Error when exporting with template #115

Closed mlwebworker closed 1 year ago

mlwebworker commented 3 years ago

Beim Export mit Template tritt folgender Fehler auf:

Attempted to load class "PHPExcel_IOFactory" from the global namespace. Did you forget a "use" statement?

Der Export ohne Template funktioniert ohne Probleme.

Contao: 4.11.5 und 4.9.16 Leads: 1.4.19 phpoffice/phpspreadsheet: 1.18.0 Export-Format: Excel 2007/2010 (.xlxs) Template-Format: .xlxs keine anderen Erweiterungen installiert.

Exception im Debug-Modus:


in F:\public_html\contao_4_9_x\vendor\terminal42\contao-leads\library\Leads\Exporter\AbstractExcelExporter.php (line 121)

            }
            $tmpPath = 'system/tmp/' . File::getName($config);
            \Files::getInstance()->copy($template->path, $tmpPath);
            $excelReader = PHPExcel_IOFactory::createReader($format);
            $excel = $excelReader->load(TL_ROOT . '/' . $tmpPath);
            $excel->setActiveSheetIndex((int) $config->sheetIndex);
            $sheet = $excel->getActiveSheet();

Stack Trace im Debug Modus:

Symfony\Component\ErrorHandler\Error\ClassNotFoundError:
Attempted to load class "PHPExcel_IOFactory" from the global namespace.
Did you forget a "use" statement?

  at F:\public_html\contao_4_9_x\vendor\terminal42\contao-leads\library\Leads\Exporter\AbstractExcelExporter.php:121
  at Leads\Exporter\AbstractExcelExporter->exportWithTemplate(object(Result), object(ArrayReader), object(Row), 'Excel2007')
     (F:\public_html\contao_4_9_x\vendor\terminal42\contao-leads\library\Leads\Exporter\AbstractExcelExporter.php:54)
  at Leads\Exporter\AbstractExcelExporter->exportWithFormat(object(Result), null, 'Excel2007')
     (F:\public_html\contao_4_9_x\vendor\terminal42\contao-leads\library\Leads\Exporter\Xlsx.php:24)
  at Leads\Exporter\Xlsx->export(object(Result), null)
     (F:\public_html\contao_4_9_x\vendor\terminal42\contao-leads\library\Leads\Leads.php:375)
  at Leads\Leads::export('1', null)
     (F:\public_html\contao_4_9_x\vendor\terminal42\contao-leads\dca\tl_lead.php:497)
  at tl_lead->exportAndCatchExceptions('1', null)
     (F:\public_html\contao_4_9_x\vendor\terminal42\contao-leads\dca\tl_lead.php:362)
  at tl_lead->export(object(DC_Table))
     (F:\public_html\contao_4_9_x\vendor\contao\core-bundle\src\Resources\contao\classes\Backend.php:441)
  at Contao\Backend->getBackendModule('lead', null)
     (F:\public_html\contao_4_9_x\vendor\contao\core-bundle\src\Resources\contao\controllers\BackendMain.php:167)
  at Contao\BackendMain->run()
     (F:\public_html\contao_4_9_x\vendor\contao\core-bundle\src\Controller\BackendController.php:48)
  at Contao\CoreBundle\Controller\BackendController->mainAction()
     (F:\public_html\contao_4_9_x\vendor\symfony\http-kernel\HttpKernel.php:158)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (F:\public_html\contao_4_9_x\vendor\symfony\http-kernel\HttpKernel.php:80)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (F:\public_html\contao_4_9_x\vendor\symfony\http-kernel\Kernel.php:201)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (F:\public_html\contao_4_9_x\web\index.php:31)                
fritzmg commented 3 years ago

I think the nominal compatibility with phpoffice/phpexcel should be dropped and all PHPExcel references should be updated to PhpOffice\PhpSpreadsheet\….

rabauss commented 1 year ago

I dropped the support for phpoffice/phpexcel in my PR for haste 5 #133 Although the export with template needs to be tested - I had no working config...

internethering commented 1 year ago

I've this problem too, is there any workaround?

testing rabauss code is atm no option on my installation:

    - codefog/contao-haste[5.0.0, ..., 5.0.16] require php ^8.1 -> your php version (7.4.33) does not satisfy that requirement.
    - terminal42/contao-leads dev-haste-5 requires codefog/contao-haste ^5.0 -> satisfiable by codefog/contao-haste[5.0.0, ..., 5.0.16].
    - Root composer.json requires terminal42/contao-leads dev-haste-5 -> satisfiable by terminal42/contao-leads[dev-haste-5].
rabauss commented 1 year ago

I think a workaround would be to also install phpoffice/phpexcel alongside phpoffice/phpspreadsheet

aschempp commented 1 year ago

this will be fixed in version 3