writting excel 7 issues but works with excel 5

Topics: User Forum
Oct 30, 2007 at 6:12 PM
Hello

I have been successful creating an Excel spreadsheet using this plug (versions 1.5) in if I save the document as an Excel 5 spread sheet. However when I change the line from

$objWriter = new PHPExcelWriterExcel5($objPHPExcel);

to

$objWriter = new PHPExcelWriterExcel2007($objPHPExcel);

I get an error

in SFROOTDIR\apps\frontend\lib\PHPExcel\Writer\Excel2007.php line 266 ...

263.
264. // Try opening the ZIP file
265. if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
266. throw new Exception("Could not open " . $pFilename . " for writing.");
267. }
268.
269. // Add Content_Types.xml to ZIP file

I don't have to use Excel 2007, its not that big of a deal, however I can't get some of the more advance features such as auto filter and conditional statements to work when I have the file in Excel 5 format. Are these features only avaliabe for Excel 2007? I have also taken the pre-witting PHP scripts from the test directory provided with the plugin and am not able to run them and have them save to an Excel 2007 version spreadsheet.
Coordinator
Oct 30, 2007 at 7:45 PM
- Can you specify which error? I think you do not have write permisisons on where you want to save the file, but not sure due to the incomplete error message.

- Yes, these features are only in Excel2007 writer. Excel5 support is actually based on PEAR Spreadsheet Excel writer, and limited to that class' feature set.
Oct 30, 2007 at 8:43 PM
Thank you for the quick reply here is the full error, It would be weird if I couldn't write out the Excel 2007 file, my test enviorment is on a Windows box that I have full Admin rights to

Could not open for writing.
stack trace

* at ()
in SFROOTDIR\apps\frontend\lib\PHPExcel\Writer\Excel2007.php line 266 ...
263.
264. // Try opening the ZIP file
265. if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
266. throw new Exception("Could not open " . $pFilename . " for writing.");
267. }
268.
269. // Add Content_Types.xml to ZIP file
* at PHPExcelWriterExcel2007->save()
in SFROOTDIR\apps\frontend\modules\server\actions\actions.class.php line 352 ...
349. //$errorreporting = errorreporting(0);
350. //$objWriter = new PHPExcelWriterExcel5($objPHPExcel);
351. $objWriter = new PHPExcelWriterExcel2007($objPHPExcel);
352. $xls_data = $this->renderText($objWriter->save());
353. //errorreporting($errorreporting);
354.
355. return $xls_data;
* at serverActions->executeExportAllServersExcel()
in SFROOTDIR\lib\symfony\action\sfActions.class.php line 53 ...
50. }
51.
52. // run action
53. $ret = $this->$actionToRun();
54.
55. return $ret;
56. }
* at sfActions->execute()
in SFROOTDIR\lib\symfony\filter\sfExecutionFilter.class.php line 115 ...
112.
113. // execute the action
114. $actionInstance->preExecute();
115. $viewName = $actionInstance->execute();
116. if ($viewName == '')
117. {
118. $viewName = sfView::SUCCESS;
* at sfExecutionFilter->execute(object('sfFilterChain'))
in SFROOTDIR\lib\symfony\filter\sfFilterChain.class.php line 43 ...
40. }
41.
42. // execute the next filter
43. $this->chain$this->index->execute($this);
44. }
45. }
46.
* at sfFilterChain->execute()
in SFROOTDIR\lib\symfony\filter\sfFlashFilter.class.php line 50 ...
47. }
48.
49. // execute next filter
50. $filterChain->execute();
51.
52. // remove flash that are tagged to be removed
53. $names = $userAttributeHolder->getNames('symfony/flash/remove');
* at sfFlashFilter->execute(object('sfFilterChain'))
in SFROOTDIR\lib\symfony\filter\sfFilterChain.class.php line 43 ...
40. }
41.
42. // execute the next filter
43. $this->chain$this->index->execute($this);
44. }
45. }
46.
* at sfFilterChain->execute()
in SFROOTDIR\lib\symfony\filter\sfCommonFilter.class.php line 29 ...
26. public function execute($filterChain)
27. {
28. // execute next filter
29. $filterChain->execute();
30.
31. // execute this filter only once
32. $response = $this->getContext()->getResponse();
* at sfCommonFilter->execute(object('sfFilterChain'))
in SFROOTDIR\lib\symfony\filter\sfFilterChain.class.php line 43 ...
40. }
41.
42. // execute the next filter
43. $this->chain$this->index->execute($this);
44. }
45. }
46.
* at sfFilterChain->execute()
in SFROOTDIR\lib\symfony\filter\sfWebDebugFilter.class.php line 35 ...
32. }
33.
34. // execute next filter
35. $filterChain->execute();
36.
37. $context = $this->getContext();
38. $response = $context->getResponse();
* at sfWebDebugFilter->execute(object('sfFilterChain'))
in SFROOTDIR\lib\symfony\filter\sfFilterChain.class.php line 43 ...
40. }
41.
42. // execute the next filter
43. $this->chain$this->index->execute($this);
44. }
45. }
46.
* at sfFilterChain->execute()
in SFROOTDIR\lib\symfony\filter\sfRenderingFilter.class.php line 33 ...
30. public function execute($filterChain)
31. {
32. // execute next filter
33. $filterChain->execute();
34.
35. if (sfConfig::get('sfloggingenabled'))
36. {
* at sfRenderingFilter->execute(object('sfFilterChain'))
in SFROOTDIR\lib\symfony\filter\sfFilterChain.class.php line 43 ...
40. }
41.
42. // execute the next filter
43. $this->chain$this->index->execute($this);
44. }
45. }
46.
* at sfFilterChain->execute()
in SFROOTDIR\lib\symfony\controller\sfController.class.php line 276 ...
273. }
274.
275. // process the filter chain
276. $filterChain->execute();
277. }
278. else
279. {
* at sfController->forward('server', 'ExportAllServersExcel')
in SFROOTDIR\lib\symfony\controller\sfFrontWebController.class.php line 48 ...
45. $actionName = $request->getParameter('action');
46.
47. // make the first request
48. $this->forward($moduleName, $actionName);
49. }
50. catch (sfException $e)
51. {
* at sfFrontWebController->dispatch()
in SFROOTDIR\web\frontend_dev.php line 10 ...
Oct 30, 2007 at 8:47 PM
Actually this has to be an issue with the way I incorporated they PHP Excel lib files with the PHP frame work (symfony) , or my code itself. When I take my code and symfony out of the picture and just run one of your sample files in the Test directory everything works fine.