aebstract Posted March 23, 2009 Share Posted March 23, 2009 Okay I am trying to just run one of their basic examples, with a slight modification (just removed the stuff that added sheet two). Going through their examples, just about everything that is done has an echo, let's you know where you're getting stuck at and whatnot. Well, here is the code for the two pages: testexcel.php <?php include "testexcel.inc.php"; /** PHPExcel_IOFactory */ include 'PHPExcel/IOFactory.php'; // Save Excel 2007 file echo date('H:i:s') . " Write to Excel2007 format\n"; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); // Echo memory peak usage echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n"; // Echo done echo date('H:i:s') . " Done writing file.\r\n"; and testexcel.inc.php <?php /** Error reporting */ error_reporting(E_ALL); /** Include path **/ set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/'); /** PHPExcel */ require_once 'PHPExcel.php'; /** PHPExcel_RichText */ require_once 'PHPExcel/RichText.php'; // Create new PHPExcel object echo date('H:i:s') . " Create new PHPExcel object\n"; $objPHPExcel = new PHPExcel(); // Set properties echo date('H:i:s') . " Set properties\n"; $objPHPExcel->getProperties()->setCreator("Maarten Balliauw"); $objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw"); $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document"); $objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document"); $objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes."); $objPHPExcel->getProperties()->setKeywords("office 2007 openxml php"); $objPHPExcel->getProperties()->setCategory("Test result file"); // Create a first sheet, representing sales data echo date('H:i:s') . " Add some data\n"; $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Invoice'); $objPHPExcel->getActiveSheet()->setCellValue('D1', time()); $objPHPExcel->getActiveSheet()->getStyle('D1')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH); $objPHPExcel->getActiveSheet()->setCellValue('E1', '#12566'); $objPHPExcel->getActiveSheet()->setCellValue('A3', 'Product Id'); $objPHPExcel->getActiveSheet()->setCellValue('B3', 'Description'); $objPHPExcel->getActiveSheet()->setCellValue('C3', 'Price'); $objPHPExcel->getActiveSheet()->setCellValue('D3', 'Amount'); $objPHPExcel->getActiveSheet()->setCellValue('E3', 'Total'); $objPHPExcel->getActiveSheet()->setCellValue('A4', '1001'); $objPHPExcel->getActiveSheet()->setCellValue('B4', 'PHP for dummies'); $objPHPExcel->getActiveSheet()->setCellValue('C4', '20'); $objPHPExcel->getActiveSheet()->setCellValue('D4', '1'); $objPHPExcel->getActiveSheet()->setCellValue('E4', '=C4*D4'); $objPHPExcel->getActiveSheet()->setCellValue('A5', '1012'); $objPHPExcel->getActiveSheet()->setCellValue('B5', 'OpenXML for dummies'); $objPHPExcel->getActiveSheet()->setCellValue('C5', '22'); $objPHPExcel->getActiveSheet()->setCellValue('D5', '2'); $objPHPExcel->getActiveSheet()->setCellValue('E5', '=C5*D5'); $objPHPExcel->getActiveSheet()->setCellValue('E6', '=C6*D6'); $objPHPExcel->getActiveSheet()->setCellValue('E7', '=C7*D7'); $objPHPExcel->getActiveSheet()->setCellValue('E8', '=C8*D8'); $objPHPExcel->getActiveSheet()->setCellValue('E9', '=C9*D9'); $objPHPExcel->getActiveSheet()->setCellValue('D11', 'Total excl.:'); $objPHPExcel->getActiveSheet()->setCellValue('E11', '=SUM(E4:E9)'); $objPHPExcel->getActiveSheet()->setCellValue('D12', 'VAT:'); $objPHPExcel->getActiveSheet()->setCellValue('E12', '=E11*0.21'); $objPHPExcel->getActiveSheet()->setCellValue('D13', 'Total incl.:'); $objPHPExcel->getActiveSheet()->setCellValue('E13', '=E11+E12'); // Add comment echo date('H:i:s') . " Add comments\n"; $objPHPExcel->getActiveSheet()->getComment('E11')->setAuthor('PHPExcel'); $objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun('PHPExcel:'); $objCommentRichText->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun("\r\n"); $objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun('Total amount on the current invoice, excluding VAT.'); $objPHPExcel->getActiveSheet()->getComment('E12')->setAuthor('PHPExcel'); $objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E12')->getText()->createTextRun('PHPExcel:'); $objCommentRichText->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getComment('E12')->getText()->createTextRun("\r\n"); $objPHPExcel->getActiveSheet()->getComment('E12')->getText()->createTextRun('Total amount of VAT on the current invoice.'); $objPHPExcel->getActiveSheet()->getComment('E13')->setAuthor('PHPExcel'); $objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E13')->getText()->createTextRun('PHPExcel:'); $objCommentRichText->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getComment('E13')->getText()->createTextRun("\r\n"); $objPHPExcel->getActiveSheet()->getComment('E13')->getText()->createTextRun('Total amount on the current invoice, including VAT.'); $objPHPExcel->getActiveSheet()->getComment('E13')->setWidth('100pt'); $objPHPExcel->getActiveSheet()->getComment('E13')->setHeight('100pt'); $objPHPExcel->getActiveSheet()->getComment('E13')->setMarginLeft('150pt'); $objPHPExcel->getActiveSheet()->getComment('E13')->getFillColor()->setRGB('EEEEEE'); // Add rich-text string echo date('H:i:s') . " Add rich-text string\n"; $objRichText = new PHPExcel_RichText( $objPHPExcel->getActiveSheet()->getCell('A18') ); $objRichText->createText('This invoice is '); $objPayable = $objRichText->createTextRun('payable within thirty days after the end of the month'); $objPayable->getFont()->setBold(true); $objPayable->getFont()->setItalic(true); $objPayable->getFont()->setColor( new PHPExcel_Style_Color( PHPExcel_Style_Color::COLOR_DARKGREEN ) ); $objRichText->createText(', unless specified otherwise on the invoice.'); // Merge cells echo date('H:i:s') . " Merge cells\n"; $objPHPExcel->getActiveSheet()->mergeCells('A18:E22'); $objPHPExcel->getActiveSheet()->mergeCells('A28:B28'); // Just to test... $objPHPExcel->getActiveSheet()->unmergeCells('A28:B28'); // Just to test... // Protect cells echo date('H:i:s') . " Protect cells\n"; $objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // Needs to be set to true in order to enable any worksheet protection! $objPHPExcel->getActiveSheet()->protectCells('A3:E13', 'PHPExcel'); // Set cell number formats echo date('H:i:s') . " Set cell number formats\n"; $objPHPExcel->getActiveSheet()->getStyle('E4')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); $objPHPExcel->getActiveSheet()->duplicateStyle( $objPHPExcel->getActiveSheet()->getStyle('E4'), 'E5:E13' ); // Set column widths echo date('H:i:s') . " Set column widths\n"; $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(12); $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(12); // Set fonts echo date('H:i:s') . " Set fonts\n"; $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setName('Candara'); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setSize(20); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE); $objPHPExcel->getActiveSheet()->getStyle('D1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE); $objPHPExcel->getActiveSheet()->getStyle('E1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE); $objPHPExcel->getActiveSheet()->getStyle('D13')->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getStyle('E13')->getFont()->setBold(true); // Set alignments echo date('H:i:s') . " Set alignments\n"; $objPHPExcel->getActiveSheet()->getStyle('D11')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle('D12')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle('D13')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle('A18')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY); $objPHPExcel->getActiveSheet()->getStyle('A18')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->getStyle('B5')->getAlignment()->setShrinkToFit(true); // Set column borders echo date('H:i:s') . " Set column borders\n"; $objPHPExcel->getActiveSheet()->getStyle('A4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('B4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('C4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('D4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('E4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('A11')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('B11')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('C11')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('D11')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('E11')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('A4')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('A5')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('A6')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('A7')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('A8')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('A9')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('A10')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('E4')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('E5')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('E6')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('E7')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('E8')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('E9')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('E10')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('D11')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('D12')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('D13')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THICK); $objPHPExcel->getActiveSheet()->getStyle('E11')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('E12')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); $objPHPExcel->getActiveSheet()->getStyle('E13')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THICK); $objPHPExcel->getActiveSheet()->getStyle('D13')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THICK); $objPHPExcel->getActiveSheet()->getStyle('E13')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THICK); $objPHPExcel->getActiveSheet()->getStyle('D13')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THICK); $objPHPExcel->getActiveSheet()->getStyle('E13')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THICK); // Set border colors echo date('H:i:s') . " Set border colors\n"; $objPHPExcel->getActiveSheet()->getStyle('D13')->getBorders()->getLeft()->getColor()->setARGB('FF993300'); $objPHPExcel->getActiveSheet()->getStyle('D13')->getBorders()->getTop()->getColor()->setARGB('FF993300'); $objPHPExcel->getActiveSheet()->getStyle('D13')->getBorders()->getBottom()->getColor()->setARGB('FF993300'); $objPHPExcel->getActiveSheet()->getStyle('E13')->getBorders()->getTop()->getColor()->setARGB('FF993300'); $objPHPExcel->getActiveSheet()->getStyle('E13')->getBorders()->getBottom()->getColor()->setARGB('FF993300'); $objPHPExcel->getActiveSheet()->getStyle('E13')->getBorders()->getRight()->getColor()->setARGB('FF993300'); // Set fills echo date('H:i:s') . " Set fills\n"; $objPHPExcel->getActiveSheet()->getStyle('A1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID); $objPHPExcel->getActiveSheet()->getStyle('A1')->getFill()->getStartColor()->setARGB('FF808080'); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFill()->getStartColor()->setARGB('FF808080'); $objPHPExcel->getActiveSheet()->getStyle('C1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID); $objPHPExcel->getActiveSheet()->getStyle('C1')->getFill()->getStartColor()->setARGB('FF808080'); $objPHPExcel->getActiveSheet()->getStyle('D1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID); $objPHPExcel->getActiveSheet()->getStyle('D1')->getFill()->getStartColor()->setARGB('FF808080'); $objPHPExcel->getActiveSheet()->getStyle('E1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID); $objPHPExcel->getActiveSheet()->getStyle('E1')->getFill()->getStartColor()->setARGB('FF808080'); // Set style for header row using alternative method echo date('H:i:s') . " Set style for header row using alternative method\n"; $objPHPExcel->getActiveSheet()->duplicateStyleArray( array( 'font' => array( 'bold' => true ), 'alignment' => array( 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_RIGHT, ), 'borders' => array( 'top' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN ) ), 'fill' => array( 'type' => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR, 'rotation' => 90, 'startcolor' => array( 'argb' => 'FFA0A0A0' ), 'endcolor' => array( 'argb' => 'FFFFFFFF' ) ) ), 'A3:E3' ); $objPHPExcel->getActiveSheet()->getStyle('A3')->applyFromArray( array( 'alignment' => array( 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT, ), 'borders' => array( 'left' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN ) ) ) ); $objPHPExcel->getActiveSheet()->getStyle('B3')->applyFromArray( array( 'alignment' => array( 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT, ) ) ); $objPHPExcel->getActiveSheet()->getStyle('E3')->applyFromArray( array( 'borders' => array( 'right' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN ) ) ) ); // Unprotect a cell echo date('H:i:s') . " Unprotect a cell\n"; $objPHPExcel->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); // Add a hyperlink to the sheet echo date('H:i:s') . " Add a hyperlink to the sheet\n"; $objPHPExcel->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net'); $objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net'); $objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setTooltip('Navigate to website'); $objPHPExcel->getActiveSheet()->getStyle('E26')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->setCellValue('E27', 'Terms and conditions'); $objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setUrl("sheet://'Terms and conditions'!A1"); $objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setTooltip('Review terms and conditions'); $objPHPExcel->getActiveSheet()->getStyle('E27')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); // Play around with inserting and removing rows and columns echo date('H:i:s') . " Play around with inserting and removing rows and columns\n"; $objPHPExcel->getActiveSheet()->insertNewRowBefore(6, 10); $objPHPExcel->getActiveSheet()->removeRow(6, 10); $objPHPExcel->getActiveSheet()->insertNewColumnBefore('E', 5); $objPHPExcel->getActiveSheet()->removeColumn('E', 5); // Set header and footer. When no different headers for odd/even are used, odd header is assumed. echo date('H:i:s') . " Set header/footer\n"; $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&BInvoice&RPrinted on &D'); $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N'); // Set page orientation and size echo date('H:i:s') . " Set page orientation and size\n"; $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT); $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4); // Rename sheet echo date('H:i:s') . " Rename sheet\n"; $objPHPExcel->getActiveSheet()->setTitle('Invoice'); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); Here is what is getting sent back to me as results: 15:20:26 Create new PHPExcel object 15:20:26 Set properties 15:20:26 Add some data 15:20:26 Add comments 15:20:26 Add rich-text string 15:20:26 Merge cells 15:20:26 Protect cells 15:20:26 Set cell number formats 15:20:26 Set column widths 15:20:26 Set fonts 15:20:26 Set alignments 15:20:26 Set column borders 15:20:26 Set border colors 15:20:26 Set fills 15:20:26 Set style for header row using alternative method 15:20:26 Unprotect a cell 15:20:26 Add a hyperlink to the sheet 15:20:26 Play around with inserting and removing rows and columns 15:20:27 Set header/footer 15:20:27 Set page orientation and size 15:20:27 Rename sheet 15:20:27 Write to Excel2007 format Which tells me, the last thing it does is this: echo date('H:i:s') . " Write to Excel2007 format\n"; and stops before it does the rest: $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); // Echo memory peak usage echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n"; // Echo done echo date('H:i:s') . " Done writing file.\r\n"; Any help on this is greatly appreciated. Thanks EDIT: I just threw in an extra echo, to isolate the exact line: $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); It's the second line in the above code, I put an echo in after the first line and it output fine. Put one after the second line and it was stopped at that point. What is wrong with this? $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); Quote Link to comment https://forums.phpfreaks.com/topic/150760-phpexcel-help/ Share on other sites More sharing options...
aebstract Posted March 23, 2009 Author Share Posted March 23, 2009 Okay, I just tested with their exact code, ended up stopping at the same spot. I used their most basic example as a test as well, ends up stopping on the same thing: <?php /** * PHPExcel * * Copyright (C) 2006 - 2009 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel * @package PHPExcel * @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 1.6.6, 2009-03-02 */ /** Error reporting */ error_reporting(E_ALL); /** Include path **/ set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/'); /** PHPExcel */ include 'PHPExcel.php'; /** PHPExcel_IOFactory */ include 'PHPExcel/IOFactory.php'; // Create new PHPExcel object echo date('H:i:s') . " Create new PHPExcel object\n"; $objPHPExcel = new PHPExcel(); // Set properties echo date('H:i:s') . " Set properties\n"; $objPHPExcel->getProperties()->setCreator("Maarten Balliauw"); $objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw"); $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document"); $objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document"); $objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes."); $objPHPExcel->getProperties()->setKeywords("office 2007 openxml php"); $objPHPExcel->getProperties()->setCategory("Test result file"); // Add some data echo date('H:i:s') . " Add some data\n"; $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello'); $objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!'); $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello'); $objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!'); // Rename sheet echo date('H:i:s') . " Rename sheet\n"; $objPHPExcel->getActiveSheet()->setTitle('Simple'); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); // Save Excel 2007 file echo date('H:i:s') . " Write to Excel2007 format\n"; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); // Echo memory peak usage echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n"; // Echo done echo date('H:i:s') . " Done writing file.\r\n"; 15:30:31 Create new PHPExcel object 15:30:31 Set properties 15:30:31 Add some data 15:30:31 Rename sheet 15:30:31 Write to Excel2007 format Is this some sort of setting I need to have enabled on my server or something? Quote Link to comment https://forums.phpfreaks.com/topic/150760-phpexcel-help/#findComment-792053 Share on other sites More sharing options...
Mark Baker Posted March 23, 2009 Share Posted March 23, 2009 There's no particular settings required, although it is necessary to have built php with a working php_zip (or enabled it). Note that there have been a number of problems with php_zip on Windows servers. Are you running on a Windows server? or *nix? Is the script actually generating a testexcel.xlsx file at all, readable or otherwise? Quote Link to comment https://forums.phpfreaks.com/topic/150760-phpexcel-help/#findComment-792057 Share on other sites More sharing options...
aebstract Posted March 23, 2009 Author Share Posted March 23, 2009 No, it's stopping before it creates a file. I just saw the requirements for this library: * PHP version 5.2 or higher * PHP extension php_zip enabled * PHP extension php_xml enabled * PHP extension php_gd2 enabled (if not compiled in) I'm currently on 5.1.6. I'm on hold waiting to talk to someone from my Host right now to see if I can get it upgraded, and ask if those php extensions are enabled or not. Just to be certain. Server is running on Linux. Quote Link to comment https://forums.phpfreaks.com/topic/150760-phpexcel-help/#findComment-792059 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.