EXcel export

Topics: Developer Forum
Mar 21, 2011 at 8:46 AM

Hi

I'm new in phpexcel

PHP version:5.2.10

phpexcel:1.6.7

But it will display blank page? i tired to try this. plz any one help.

otherwise suggest me any other excel export with formatting cells. i want to integrate with my application

please help friends.

Mar 21, 2011 at 9:25 AM

Hi,

 

could you give a little more detail in what is happening?

What code are you using?

Does the webserver return a blank page (As in, is the response totally empty)? what headers are you receiving? are there any errors in phplog, of\r in apache error log. What happens if you include some debug statements in your code?

 

Mike

 

PS you should really consider upgrading your php, as php 5.2 is deprecated and will no longer be supported

Mar 21, 2011 at 9:33 AM

hi

yes WebServer was return the blank page.  it was didn't throw any error but total response is blank page.

Not possible to upgrade my server now. so, please give me a idea for that

<?php

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";

?>

Mar 21, 2011 at 9:43 AM

What level is your error reporting set at? Since there is no output, it would seem your script dies before the "echo data". Do you perhaps have output buffering enabled? Can you confirm that PHP is working? (craete a new script with only:

<?php
phpinfo();
?>

to check that. Furthermore adding more error reporting (at the top of your script) may help:

error_reporting(E_ALL);


Mike