Home Features Requirements Examples FAQ Contribute Documents Credits Contact

Examples

Examples can be found in the test package in the latest release.

File examples

The following examples are included, each representing another feature of PHPExcel:

Hello World example

A simple "Hello World" example, which results in a file like 01simple.xlsx:
<?php
/** Error reporting */
error_reporting(E_ALL);

/** Include path **/
ini_set('include_path', ini_get('include_path').';../Classes/');

/** PHPExcel */
include 'PHPExcel.php';

/** PHPExcel_Writer_Excel2007 */
include 'PHPExcel/Writer/Excel2007.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.");


// 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');

		
// Save Excel 2007 file
echo date('H:i:s') . " Write to Excel2007 format\n";
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));

// Echo done
echo date('H:i:s') . " Done writing file.\r\n";

Last edited Aug 7, 2007 at 8:40 AM by maartenba, version 12

Comments

statcruncher Tue at 2:50 PM 
Trying to run the 07reader.php example on my server. Unfortunately, the script dies when trying to execute the load statement on line 47. Nothing is shown in the browser even with the error reporting turned on. In the server logs, the only relevant errors seems to be

[Tue Nov 18 08:57:38 2014] [error] [client 10.0.4.139] PHP Notice: Undefined property: PHPExcel_Calculation::$_savedPrecision in /vh/docroots/sc.pearsoncmg.com/htdocs/PHPExcel1.8/Classes/PHPExcel/Calculation.php on line 1739
[Tue Nov 18 08:57:38 2014] [error] [client 10.0.4.139] PHP Notice: Undefined property: PHPExcel_Calculation::$_savedPrecision in /vh/docroots/sc.pearsoncmg.com/htdocs/PHPExcel1.8/Classes/PHPExcel/Calculation.php on line 1740

An older version of PHPExcel (1.6.6) works fine on the server, but 1.8 does not. Any help would be greatly appreciated.

mannielucero Jul 23 at 6:08 PM 
Hello, I made a php script that parses xls file. It works well but the only problem is that

when php read the cell it only reads 7/21/2014 0:43

also when i go to the xls and click the cell it shows the right format which is

7/21/2014 12:21:05 AM
why does xls hides it?

how can i convert that?

when i use $date_time = date('Y-m-d H:i:s', strtotime($date));

to format it took away the seconds it only returns 2014-07-21 00:43:00

please help me, is there a way i can convert it back to hh:mm:ss format (having the seconds).

This is what the output i need:

2014-07-21 12:21:05

Thank you.

wiam Apr 8 at 2:50 PM 
Hi everyone!! please i want to know how to place the pointer in the end of an xlsx file in order to copy more than one txt file in my excel file.
In fact, i have a php program that read a .txt file and copy it in an excel file. I want to make modification to my program to allow it to copy all my txt files in only one excel file.
Pleaaaaaaaaaaaaase help me !!!! thanks

cavaliercyber Jul 28, 2013 at 2:23 PM 
I wonder if it has a feature which can only generate excel file by input of function is only sql query.
e.g.
function genExcel(string sqlquery)
{
xxxxx
xxxxx
return excel or string that header can convert to excel.
}

thanks

HemaliSanghvi Jul 15, 2013 at 10:55 AM 
I want to add replace command
$objPHPExcel->getActiveSheet()->setCellValue('B2', '=REPLACE("'.mysql_result($result, $i, 'merchant_id').'"|1|1|)');
This is because i need to remove my first character. My file doesn't responding anything. can any body help me?

rixsoria Jun 20, 2013 at 1:52 PM 
Hi, How can I fix, this?
I mean why this file has this problem...

Fatal error: Class 'ZipArchive' not found in C:\Program Files (x86)\Apache Group\Apache2\htdocs\pruebas\PHPExcel\Writer\Excel2007.php on line 205

gp92300 Jun 17, 2013 at 10:25 AM 
Works just fine in Joomla!

hackestat May 17, 2013 at 5:49 PM 
hi Guys, is it possible to insert a checkbox by using PHPexcel library on a excel file, generated from a SQL server table query?

hemadoubt Apr 4, 2013 at 2:00 PM 
Anyone can help me. i need a generate excel file set password protection source code. please share your comments

diegogamboa Sep 5, 2012 at 4:16 PM 
Hi,
To fix this problem you need config php.ini file. Find zlib.output_compression = off, switch off by on.

zamboo Aug 14, 2012 at 3:42 AM 
Hello all,

I'm running first time test to see my configuration of PHPExcel on 01simple.php:

I receive following error:

03:31:15 Set document properties
03:31:15 Add some data
03:31:15 Rename worksheet
03:31:15 Write to Excel2007 format

Fatal error: Uncaught exception 'PHPExcel_Exception' with message 'Cell coordinate can not be zero-length string' in C:\xampp\htdocs\kkvt\2\Classes\PHPExcel\Cell.php:528 Stack trace: #0 C:\xampp\htdocs\kkvt\2\Classes\PHPExcel\Cell.php(584): PHPExcel_Cell::coordinateFromString('') #1 C:\xampp\htdocs\kkvt\2\Classes\PHPExcel\Writer\Excel2007\Workbook.php(364): PHPExcel_Cell::absoluteCoordinate('') #2 C:\xampp\htdocs\kkvt\2\Classes\PHPExcel\Writer\Excel2007\Workbook.php(280): PHPExcel_Writer_Excel2007_Workbook->_writeDefinedNameForAutofilter(Object(PHPExcel_Shared_XMLWriter), Object(PHPExcel_Worksheet), 0) #3 C:\xampp\htdocs\kkvt\2\Classes\PHPExcel\Writer\Excel2007\Workbook.php(83): PHPExcel_Writer_Excel2007_Workbook->_writeDefinedNames(Object(PHPExcel_Shared_XMLWriter), Object(PHPExcel)) #4 C:\xampp\htdocs\kkvt\2\Classes\PHPExcel\Writer\Excel2007.php(277): PHPExcel_Writer_Excel2007_Workbook->writeWorkbook(Object(PHPExcel), true) #5 C:\xampp\htdocs\kkvt\2\Tests\01simple.php(80): PHPExcel_Writer_Excel2007->save('C:\xampp\htdoc in C:\xampp\htdocs\kkvt\2\Classes\PHPExcel\Cell.php on line 528

ANY HELP WILL BE MOSTLY APPRECIATED TO SOLVE THIS PROBLEM. THANKS IN ADVANCE.

kamy Jul 18, 2012 at 9:46 PM 
Does anyone else have problems installing and running this script?
I meet all the requirements, installed the script in a folder in my htdocs.
Copied the example script from this page, but I keep getting all sorts of include errors. I checkd actually the PHPExcel.php file is not included with the zipped package!!

Any ideas?

tx

jamarchi Jun 21, 2012 at 4:33 PM 
Hi.... I don´t know why... I just inserted this code and I got the same error messege

$porcentaje = 0;
for ($y=0; $y<$x; $y++)
{
$x = $respuestas[$y][2]*100;
$porcentaje = $x/$votos_totales;
$respuestas[$y][3] = $porcentaje;
}

What can be de problem ?

ferozsho Apr 19, 2012 at 7:50 PM 
Hello!
there is no example for reading the worksheet Data in all your example is saving to another file!!!
atleast put the example to how to read the xls file in proper manner....

chenio Oct 4, 2011 at 3:59 PM 
Fatal error: Class 'ZipArchive' not found in

i'm using php 5.2x, the correct form to compile is --enable -zip

this is line tha used for compliling


'./configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-pgsql=/opt/PostgreSQL/9.0' '--with-zlib-dir' '--with-gd' '--with-curl' '--enable-mbstring' '--with-mysql' '--with-mysqli=/usr/bin/mysql_config' '--with-freetype-dir=/usr/include/freetype2/' '--enable-zip'


greetings


sorry for my English

roby01 May 26, 2011 at 2:29 AM 
@MarkBaker
I have visited http://www.php.net/manual/en/ref.zip.php
I have downloaded php_zip.dll and set extension=php_zip.dll in php.ini and restart apache, but "Fatal error: Class 'ZipArchive' not found in" still appear

what should i do next ?....

roby01 May 25, 2011 at 10:20 AM 
I have downloaded php_zip.dll and set extension=php_zip.dll in php.ini and restart apache, but "Fatal error: Class 'ZipArchive' not found in" still appear

what should i do next ?....

rahul1234 May 19, 2011 at 11:46 AM 
I used phpexcel and my application is on godaddy server. I have Zip, Zlib, xml enabled on godaddy's phpinfo file. but my final download excel not downloading properly. It is displaying Invalid format before it downloading the file and when I opens the file it is showing some zigzag unicode messages. please help me

Also please tell me, do I need PHP PEAR to be enabled for PHPExcel to work properly?

stiffa Apr 20, 2011 at 10:11 AM 
Hello. How i can write a row in the same file excel that I read before?
I want read a file : loop all rows , and after last row I want write a new row.
Help pls.
Thx

lohe Apr 12, 2011 at 6:39 PM 
hey,
first - nice job on that one.. it had to be hard:)

second - I cannot get cell format to work. I want to assign format_number_00 for certain cells but it won't apply. is there any kind of lineup which to follow? or any settings to allow?
Thanks,
lohe

thenndral Feb 24, 2011 at 1:51 AM 
Hi,
Thanks for the great code. I just started with tests folder code.
I have a problem while save excel.
I don't know where I did mistake.

Everything goes fine, when this line comes
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
browser displays "This Page appears broken"

I'm using php5.2 and excel2007.

Thanks,
Thenndral

MarkBaker Jan 20, 2011 at 10:23 PM 
@macotamayo
The PHPExcel object is just that, an object: not a stream. I'm not sure what you are trying to do, but you can pass the PHPExcel object to one of the writers and then save to php://output... remembering that you'll need to send the appropriate headers first

macotamayo Jan 19, 2011 at 1:26 PM 
Is there A way to get the stream value for the of the PHPExcel object? I just what to flush it, not saving it. Or is there an available binary writer for it?
Thanks

klevismiho Dec 10, 2010 at 11:45 AM 
It would be nice to have some "How to's" here.

MarkBaker Oct 1, 2010 at 11:11 PM 
@nictan
Take a look at this thread ( http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=228880 ) which gives a simple example of reading from a file, changing the contents, then writing to another file. Just modify that so that the write save to the same name as the file you read from.

nictan Sep 30, 2010 at 1:55 AM 
i will like to check for the codes am i able to read the excel file and write to the same excel file that i have read. if it is possible can someone point me to the right direction thanks!

MarkBaker Sep 3, 2010 at 6:23 PM 
@aldm
Not that I'm aware of. PHP (and PHPExcel) runs on the server. I'd assume from your description that the files that are hyperlinked in your spreadsheet are on the client PC. Therefore, PHP cannot access them unless the client explicitly uploads them to the server.

aldm Sep 2, 2010 at 11:30 AM 
Hi,

is there a posibility to get the file which is represented as hyperlink in excel and upload that file on server in php script?

I have a database with table articles and I want to enable users to input their data from excel table (for example, 10 articles at once).
One of the attributes in table Articles is picture. In database, there is only name of picture and pictures are stored on server.

I know how to upload picture on server (move_uploaded_file).
But, how can this be implemented. Is the file upload only way to store data on server and how could I do this.

Thanks in advance,

Amer

MarkBaker Aug 20, 2010 at 10:55 AM 
@Dezarr Can you tell us the formula that is causing this problem? I assume that you are following the locale instructions outlined in the documentation for using non-English languages for formulae.

Dezarr Aug 12, 2010 at 5:17 PM 
Hello! I've a problem. I tried to put some information in cells on the first sheet. Other sheets contains formula include information from first sheet. Formulas wrote on Russian. When I tried to put information I receved error:
Fatal error: Uncaught exception 'Exception' with message 'Formula Error: An unexpected error occured' in R:\home\clients\www\Classes\PHPExcel\Calculation.php:2088 Stack trace: #0 R:\home\clients\www\Classes\PHPExcel\Cell.php(285): PHPExcel_Calculation->calculateCellValue(Object(PHPExcel_Cell), true) #1 R:\home\clients\www\Classes\PHPExcel\Writer\Excel2007\Worksheet.php(969): PHPExcel_Cell->getCalculatedValue() #2 R:\home\clients\www\Classes\PHPExcel\Writer\Excel2007\Worksheet.php(910): PHPExcel_Writer_Excel2007_Worksheet->_writeCell(Object(PHPExcel_Shared_XMLWriter), Object(PHPExcel_Worksheet), 'B1', Array, Array) #3 R:\home\clients\www\Classes\PHPExcel\Writer\Excel2007\Worksheet.php(82): PHPExcel_Writer_Excel2007_Worksheet->_writeSheetData(Object(PHPExcel_Shared_XMLWriter), Object(PHPExcel_Worksheet), Array) #4 R:\home\clients\www\Classes\PHPExcel\Writer\Excel2007.php(258): PHPExcel_Writer_Excel2007_Worksheet->writeWorksheet(Object(PHPExcel_Worksheet), Array) #5 R:\home\clients\www\print.php(42): PHPExcel_Writer_Excel200 in R:\home\clients\www\Classes\PHPExcel\Calculation.php on line 2088

I changed the parameter separatpor from ; to , But is no change.

kyc Jun 25, 2010 at 10:21 AM 
have just encountered the following problem:

To load a large XML file and save it as an XLSX (Excel2007) file using test example "XMLReader.php" which is include in the latest PHPExcel package.

The size of the xml file is 1.57MB.

The message I got is:

04:19:25 Load from XML file
Fatal error: Maximum execution time of 30 seconds exceeded in C:\WAMP20\www\Test\PHPExcel\Classes\PHPExcel\Style.php on line 502

I have try to increase the timeouts setting in php.ini from 60sec to 300sec. The same message appeared.

The program works properly if I cut the size of the xml file to around 338K. So I think it is properly due to the size of file!!

I wonder if anybody can help me on this? Is this the limitation of PHPExcel ?

KYC

3rdear May 28, 2010 at 12:56 PM 
Sorry, that directory is Classes/PHPExcel/Writer/Excel2007 NOT Classes/PHPExcel/Writer/Excel_2007 (no underscore)

3rdear May 28, 2010 at 12:55 PM 
Okay, it appears that in my case, there was a permissions issue on the Classes/PHPExcel/Writer/Excel_2007 directory. odalton, if you're reading this and your problem is anything related to mine and you haven't solved your problem yet, make sure permissions are something like drwx--r-x--r-x on the above Excel_2007 directory so there is access to StringTable.php

3rdear May 28, 2010 at 12:34 PM 
Found what appears to be the source of the error on the save function. See below from my error log:

[Fri May 28 07:29:27 2010] [error] [client ::1] PHP Fatal error: Class
'PHPExcel_Writer_Excel2007_StringTable' not found in
/var/www/kiosk/includes/Classes/PHPExcel/Writer/Excel2007.php on line 143

3rdear May 26, 2010 at 10:18 PM 
I'm having the same problem as odalton. It's weird that the save function seems to be failing. In my case it works on my development machine (Kubuntu 10.04, php 5.3), but it fails on the machine I'm trying to install the app on for my client (Ubuntu 10.04 php 5.3). Aside from the desktop environment, I can't see anything of any major difference between these two machines. They both have the same stuff. When I noticed that 1.7.3 was released, I downloaded that and replaced everything with the new version. Still no luck. And I'm not seeing anything in the error log either. I'm going to check my error logging settings, but between my own procedure, query and error logging, as well as php & apache logging, you'd think something would pop up somewhere, No dice. other than that, I'd say great work. If I can figure our what's hosing up the save function on the other machine, I'd be a real happy camper.

odalton Apr 27, 2010 at 11:21 PM 
hi i have been using the phpexcel script on my dev and localhost boxes - amazing scripts 100% - just now migrated the project to another live server and was having some issues with not having the php_zip extension compiled but all sorted now extensions that is... the script fails when it gets to the save() function - is anyone encoutered this issue before????? error log not saying anything which is lame - heres the script...


this is how im saving - just dies on the save function - but worked on other boxes.... any ideas ..

$save_as_name = $results_itunes[TABLE__ITUNES__TITLE].".xlsx";

$new_save_as_name = str_replace(" ", "", $save_as_name);

// 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);

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
//$objWriter->save(str_replace('.php', '.xlsx', __FILE__));

//testing renaming the excel sheet being produced after metadata is submitted....
//$objWriter->save($results_itunes[TABLE__ITUNES__TITLE].".xlsx");
$objWriter->save($new_save_as_name);

new_bies Mar 26, 2010 at 9:18 AM 
hey, anyone who has a great solution of this error?

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 1008 bytes) in C:\xampp\htdocs\abc\library\PHPExcel\Cell.php on line 996

new_bies Mar 19, 2010 at 4:05 AM 
@MarkBaker
Thanks for the reply.. i guessed have figured out the answer...

$this->excel_generator->output('abc - '.date("Y-m-d").'.xls');

MarkBaker Mar 18, 2010 at 10:29 AM 
@Elion
We're not going to rewrite the existing load/save functionality, because that would significantly reduce the flexibility of what we can do with PHPExcel. However,. there's nothing to stop you extending the PHPExcel class itself to work the way you want it to work.

>> " and ofcorse ther is no need to write-read file each time some-one opens page, but i can't find in examples other way to display Exsel file in browser.
There isn't, but you'd need to hold the Excel file (or PHPExcel object) in persistent storage somehow (e.g. in APC or memcache, or as a serialised session object) if you wanted it to persist across requests; or write it to file the first time it was generated and then simply stream that file to the browser whenever it was requested.

MarkBaker Mar 18, 2010 at 10:09 AM 
@new_bies
No. That's not a limitation of PHPExcel, but of the http protocol
You're trying to output the date with a mime type of text/html, and the Excel file with a mime type of application/vnd.ms-excel in one go; but the http protocol only supports one mime type at a time. You'll likely get the first mime type being used (the date display) and the browser will then try to render the binary stream that comprises the excel file so that it appears as garbage on the screen.

new_bies Mar 18, 2010 at 4:16 AM 
hi, jux wondering, is it able to display date with the file name together??

$this->excel_generator->output(echo date('H:i:s') ."abc_list.xls"); ????

Elion Mar 15, 2010 at 3:35 PM 
hi mark,
thx u very match 4 this project, but it is a very hard coded and hard to understand, it can be match easer if u change it functional interface. U can add easer functions like this:
class PHPExcel{
...
function Save($excel, $name){
$type=substr($name, -4);
if($type='xlsx'){
$objWriter = new PHPExcel_Writer_Excel2007($excel);
$objWriter->save($name.'.'.$type);
}
elseif($type='.xls'){
...
}
elseif($type=('html'|'.php'|'.htm')){
...
}
}
and load function code:
"$myXLS = PHPExcel::load('some.xls');
echo $myXLS->toHTML(); "
is match easer then:
"
$objPHPExcel = PHPExcel_IOFactory::load("some.xls");
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('some.html');
echo fread($fopen('some.html', 'r'), filesize('some.html'));
" and ofcorse ther is no need to write-read file each time some-one opens page, but i can't find in examples other way to display Exsel file in browser.

diplopito Feb 3, 2010 at 2:44 PM 
Mark, thanks a lot, sorry to take your time with this small issue. I"m enjoying it now a lot.

Cheers!

Diplo

MarkBaker Feb 2, 2010 at 9:14 AM 
@diplopito
That's fine! The 01simple.php test script simply generates the excel file in the Tests directory. Other scripts there, such as 01simple-download-xls.php or 01simple-download-pdf.php demonstrate how to send the file directly to the user's browser rather than store it on the server.

diplopito Feb 2, 2010 at 2:57 AM 
Hi Mark,

Thanks for your reply. Genius is in the details;-) I set permissions to 777 and tried again: now at the end appears "Done writing file", the file is generated but it's not being exported to the user: is this fine?

Thanks again,

Diplo

MarkBaker Jan 31, 2010 at 8:08 PM 
@diplopito
Are you seeing any message to indicate that PHPExcel has "Done writing file"?

The script should create the file as 01simple.xlsx in the Tests directory, but without any error message it's hard to identify why this isn't being created. Obvious things to check are that Apache/PHP has privilege to write to that directory.

diplopito Jan 31, 2010 at 6:49 AM 
Hi,

Great project, can't wait to start working with it. I'm stuck at the very beginning:

When I run /Tests/01simple.php this is the result displayed in the browser:

07:45:37 Create new PHPExcel object 07:45:37 Set properties 07:45:37 Add some data 07:45:37 Rename sheet 07:45:37 Write to Excel2007 format

No excel file created, neither in the Tests folder. I'm using:

PHP version: 5.2.6
PHPExcel: 1.7.2

Which could be the problem?

Thanks in advance,

Diplo

MarkBaker Jan 30, 2010 at 8:12 PM 
@shumoher
There's nothing wrong with it. The messages displayed are exactly what I'd exepect to see. Have you looked at the file that is generated? You can find it in the same directory as the script itself. If you expected it to be displayed in the browser, then test scripts such as 01simple-download-xlsx.php will demonstrate that.

shumoher Jan 29, 2010 at 12:56 AM 
My output is as below on the spread sheet :
11:32:09 Set properties
11:32:09 Add some data
11:32:09 Rename sheet
11:32:09 Write to Excel2007 format
11:32:09 Done writing file.

any idea what's wrong with it?

koyama Nov 12, 2009 at 2:54 AM 
@yusuf: Your xls template was probably created in MS Office Excel 2007 as #f2f2f2 is not a standards palette color in MS Office Excel 2003 (BIFF8). You should probably avoid using non-standard palette colors if your audience only has MS Office Excel 2003 in which case they will not see such extended color information (but only the closest standard color).

With that said, Excel5 reader in latest source code (PHPExcel 1.7.1+) supports RGB colors that are stored as extended color information (XFEXT) so you may have better luck with that. If you need further information, explain the problem in a discussion post in the forum, and we will try to answer there.

yusuf Nov 11, 2009 at 10:31 AM 
ı have xls template, title cells bg color : #d8d8d8, description cell bgcolor color : #f2f2f2.
when ı try to write in my template ı get all cellbg colors only #d8d8d8.
all cells with bg color #f2f2f2 replaced with #d8d8d8..
pls help, it s a big template with 120 rows :(

MarkBaker Oct 4, 2009 at 11:44 AM 
@Intercolombia
It looks as though you're using a semi-colon (;) as a parameter separator. The PHPExcel calculation engine requires a comma (,) as the parameter separator

$E->getActiveSheet()->setCellValue('L6','=IF(K6,K6,IF(J6=0,I6,0))');

Intercolombia Sep 15, 2009 at 9:56 PM 
Hello I have a problem. Please can u help me?
I tryed to put in a cell the formula:

$E->getActiveSheet()->setCellValue('L6','=IF(K6;K6;IF(J6=0;I6;0))');

And the excecution always print this error:

Fatal error: Uncaught exception 'Exception' with message 'Formula Error: An unexpected error occured' in /home/dsfarmed/public_html/Control/inc/Excel/PHPExcel/Calculation.php:2860 Stack trace: #0 /home/dsfarmed/public_html/Control/inc/Excel/PHPExcel/Calculation.php(2442): PHPExcel_Calculation->_raiseFormulaError('Formula Error: ...') #1 /home/dsfarmed/public_html/Control/inc/Excel/PHPExcel/Calculation.php(1883): PHPExcel_Calculation->_parseFormula('IF(K6;K6;IF(J6=...') #2 /home/dsfarmed/public_html/Control/inc/Excel/PHPExcel/Calculation.php(1780): PHPExcel_Calculation->_calculateFormulaValue('=IF(K6;K6;IF(J6...', 'L6', Object(PHPExcel_Cell)) #3 /home/dsfarmed/public_html/Control/inc/Excel/PHPExcel/Cell.php(281): PHPExcel_Calculation->calculateCellValue(Object(PHPExcel_Cell), true) #4 /home/dsfarmed/public_html/Control/inc/Excel/PHPExcel/Writer/Excel2007/Worksheet.php(985): PHPExcel_Cell->getCalculatedValue() #5 /home/dsfarmed/public_html/Control/inc/Excel/PHPExcel/Writer/Excel2007/Worksheet.php(929): PHPExcel_Writer_Excel in /home/dsfarmed/public_html/Control/inc/Excel/PHPExcel/Calculation.php on line 2860

What is wrong? thanks.

samaj Jul 14, 2009 at 2:01 PM 
and also i would like to save one copy of xlsx file in my another folder for the backup so please say to me how can i set this

samaj Jul 14, 2009 at 1:58 PM 
Hy , i used this code for the applying the reachtext but it cant working so hepl me
i would like to highlite some text in difert font,style bold so i thinki have to use rach text but it's can't working so please help me

$objRichText = new PHPExcel_RichText();
$objRichText->createText('saome text');
$objPayable = $objRichText->createTextRun('saometextfor highlight');
$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.');

$objPHPExcel->getActiveSheet()->getCell('A'.$ROW)->setValue($objRichText);

Aslan2000 May 7, 2009 at 7:26 PM 
Hi! Please hekp me. How to download PHPExcel 1.6.7?

skeef Apr 7, 2009 at 6:29 AM 
Hi!
How do I find the last cell/row in xlsx document?
Thanks all

koyama Feb 24, 2009 at 6:31 AM 
@mira360: You need to increase memory limit. Check this thread:
http://www.codeplex.com/PHPExcel/Thread/View.aspx?ThreadId=36847
If you need more help, you can also try posting in the discussions.

mira360 Feb 23, 2009 at 6:59 PM 
URGENT HELP PLEASE

many times i have this error mensage on my aplication:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 393216 bytes) in.........
¿why? i need to change any parameter ¿Where?
thanks all

mira360 Feb 21, 2009 at 1:33 AM 
ok thanks i find the solution on a examples, thank you and excuse me.

echo date('H:i:s') . " Load from Excel2007 file\n";
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load("05featuredemo.xlsx");

echo date('H:i:s') . " Write to Excel2007 format\n";
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));

mira360 Feb 21, 2009 at 1:24 AM 
please help!!!
i try to use a xls template, open and write on this template.
Can you write a example? please.

xxxbetoxxx Nov 23, 2008 at 12:03 AM 
A COMPLETE EXAMPLE

/** Error reporting */
error_reporting(E_ALL);

/** Include path **/
ini_set('include_path', ini_get('include_path').';../Classes/'); //Classes dir

/** PHPExcel_IOFactory */
include 'PHPExcel/IOFactory.php';

$objReader = PHPExcel_IOFactory::createReader('Excel2007');//excel2007
$objPHPExcel = $objReader->load("c:\profile.xlsx"); //ARCHIVE excel2007 dir
$val = ($objPHPExcel->getActiveSheet()->getCell('A1')); //CELL
$temp = $val->getvalue();//returns the value in the cell

xxxbetoxxx Nov 22, 2008 at 11:58 PM 
hi!!
this is a example parsing Excel 2007 file

$objReader = PHPExcel_IOFactory::createReader('Excel2007');//use excel2007
$objPHPExcel = $objReader->load("c:\profile.xls"); //DIR ARCHIVE
$val = ($objPHPExcel->getActiveSheet()->getCell('A1')); //CELL
$temp = $val->getvalue();//returns the value in the cell

BYE!!

skeef Nov 19, 2008 at 5:08 PM 
Hi!
Please, write any examle parsing Excel2007 file.
Thanks

kv3184 Jul 21, 2008 at 4:24 PM 
Y have the same problem as nathank, I need to read the cells in a .xlsx file. I'm using the same lines but I can't get the information. Help me please.

nathank Jun 29, 2008 at 7:31 AM 
I got to know how to do it, use
$objReader = PHPExcel_IOFactory::createReader('Excel5');//use excel2007 for 2007 format
$objPHPExcel = $objReader->load("c:\profile.xls");
$val = ($objPHPExcel->getActiveSheet()->getCell('A1'));
$temp = $val->getvalue();//returns the value in the cell

nathank Jun 28, 2008 at 8:42 PM 
Iam trying to read a cell value in a .xls file. Which function shoud I use. The example code is not having any function which does this functionality. or internet I couldnt get the information.
Any help?

ck862 May 20, 2008 at 9:06 AM 
Well Done!
Hey Guys! Read the documentation first plz!
The following software is required to develop using PHPExcel:
» PHP version 5.2 or newer
» PHP extension php_zip enabled

xinhaozheng Dec 10, 2007 at 8:24 AM 
any support for utf-8?i i can not insert chinese text in the file when use excel5.

l0fty Jul 26, 2007 at 9:52 AM 
This is a really cool project, I am having one difficulty though. I am more interested in the reading of the excel files and parsing information into a database.
When I run the script from the cli version it works just fine, when trying it through a browser I get the following error..

Warning: simplexml_load_file(zip://05featuredemo.xlsx#_rels/.rels) [function.simplexml-load-file]: failed to open stream: No such file or directory in C:\apache\coolscripts\excel\Classes\PHPExcel\Reader\Excel2007.php on line 85

any ideas?

funjay Jul 13, 2007 at 12:22 AM 
Is there somewhere I can get sample code for the other examples? Specifically the conditional format example?

handrea Jul 4, 2007 at 10:34 PM 
Hi there. I need to open the file . How I do that???? But I only find that I can save it.

If someone knows please help me.

perry76 Jul 2, 2007 at 3:07 PM 
Hi there. I have the same problem as freddy1984. When I run any example: "15:59:54 Create new PHPExcel object 15:59:54 Set properties 15:59:54 Add some data 15:59:54 Rename sheet 15:59:54 Write to Excel2007 format
Fatal error: Class 'ZipArchive' not found in /home/****/****/*******/Classes/PHPExcel/Writer/Excel2007.php on line 243"

Please explain to us what the problem is.

Regards,
PB, Sweden

freddy1984 Jun 30, 2007 at 10:40 AM 
Hello! I have the problem when execute the first example. I use wamp (php5 and php_zip.dll enabled). the problem is this:
Fatal error: Class 'ZipArchive' not found in C:\wamp\www\1.3.5\Classes\PHPExcel\Writer\Excel2007.php on line 243.
What is the problem? Can you explain to me?
Thanks

MarkBaker Jun 20, 2007 at 12:36 PM 
bdp -> You need to have a build of PHP with Zip enabled.
Visit http://www.php.net/manual/en/ref.zip.php for instructions on how to do this

bdp Jun 13, 2007 at 3:26 AM 
I don't understand the file excel where is saved ???
where is the object "ZipArchive" ($objZip = new ZipArchive()) ?
i don't understand the object "ZipArchive" in the function "save" in the file "Excel2007.php" ?
can u explain to me ?
thanks