import data from mysql data base to excel

Topics: User Forum
Mar 14, 2010 at 10:35 AM

Hello,

I'm new hier. For the present I'm sorry for my English. (I wrote this question in a another part of this website, but I think it was a wrong part, so I write it again)

A friend of mine recommended this website and I'm trying since a while to understand how I can use the classes from this website. I've downloaded the packet 1.7.2.zip into my server and I've unzipped. First I've tested the testfiles, but it doesnt really work. For example I've tested '1.7.2/Tests/01simple.php', the result is:

'04:45:36 Create new PHPExcel object 04:45:36 Set properties 04:45:36 Add some data 04:45:36 Rename sheet 04:45:36 Write to Excel2007 format' this text ist showd in the browser instead a excel table.

Anyway I've read all of the discussions which is connected with 'import data from mysql data base to  excel'. I choosed a example from the discussion and put it into my programm code.   

error_reporting(E_ALL);

ini_set('include_path', ini_get('include_path').';../Classes/');

include 'PHPExcel.php';

include 'PHPExcel/Writer/Excel2007.php';

include 'PHPExcel/Writer/Excel5.php';
include 'PHPExcel/IOFactory.php';
$erg=mysql_query($abfrage)
$row = 1; $objPHPExcel = new PHPExcel();
while ($row = mysql_fetch_array($erg, MYSQL_NUM)) { $column = 'A';
foreach($row as $columnData)
{ $cellRef = $column.$row; $objPHPExcel->setActiveSheetIndex(0)->setCellValue($cellRef, $columnData);
$column++; } $row++; }

file echo date('H:i:s') . " Write to Excel2007 format\n";
echo date('H:i:s') . " Done writing file.\r\n";

objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));


the result is: there is no excel table and no error reporting. What is wrong hier? Can someone help me please?
the server which my programm lokates in : Apache2 (is a extern server)
my system software: windows vista
the programm is in utf-8 format

thank you
Developer
Mar 15, 2010 at 11:52 PM
tungaa wrote:

A friend of mine recommended this website and I'm trying since a while to understand how I can use the classes from this website. I've downloaded the packet 1.7.2.zip into my server and I've unzipped. First I've tested the testfiles, but it doesnt really work. For example I've tested '1.7.2/Tests/01simple.php', the result is:

Try to run 1.7.2/Tests/01simple-download-xlsx.php instead. You should get a download prompt when you point to that script with your browser. The other example saves the Excel file on the server which is apparently not what you want.

Mar 16, 2010 at 9:20 PM

Thank you Koyama,

I've tryed to run "01simple-download-xlsx.php" and "01simple-download-xls.php" on my server. There is a Error: 'The file was not found'.

I thought there is a maybe a Problem with my server, so I've tryed to run those two programms on my local server.

Theres is a error: Fatal error: Class 'IteratorIterator' not found in C:\apachefriends\xampp\htdocs\Tunga\Classes\PHPExcel\Worksheet\CellIterator.php on line 56

What is wrong?

tungaa


 

Coordinator
Mar 16, 2010 at 10:33 PM
tungaa wrote:

Theres is a error: Fatal error: Class 'IteratorIterator' not found in C:\apachefriends\xampp\htdocs\Tunga\Classes\PHPExcel\Worksheet\CellIterator.php on line 56

What is wrong?

 What version of PHP are you running?

IteratorIterator is part of the SPL package that is available by default in builds of PHP since version 5.0.0 (although it could be disabled) and is always compiled in from version 5.3.0

Mar 16, 2010 at 11:10 PM

The php version on my local server is 5.0.2

 

Developer
Mar 17, 2010 at 4:42 AM
tungaa wrote:

The php version on my local server is 5.0.2

 

You will need at least PHP 5.2.x