String cells with one char came empty in PHP 5.1

Topics: Developer Forum
Nov 18, 2009 at 4:36 PM

Hi,

i know that the requirement is php 5.2, but PHPExcel is reading Excel5 files correctly in 5.1.6.

The only problem is that string cells with only one cell come empty in $cell->getValue().  If the cell is a number or a string that has more than 1 char, then it works great.

Any clue on why this is happening?

Thanks,

Joel

Nov 19, 2009 at 12:39 AM
Edited Nov 19, 2009 at 12:43 AM

I've just started working with PHPExcel, and I'm encountering a similar problem --our application writes out a spreadsheet, and, if the application passes one letter to $cell->setValue(), then the cell in the written spreadsheet winds up blank. If the application passes two or more letters, then all is good.

I haven't found a solution either, but here are some more data points:

  • Debugging confirms that the application is passing the expected values into $cell->setValue().
  • We have three systems running the same revision of the same PHP application.
    • Staging and production systems run Debian Etch (with PHP 5.2.0-8+etch13). The problem has applied consistently in every test I run here.
    • A personal development machine runs Ubuntu 8.10 (with PHP 5.2.6-2ubuntu4). I have been unable to reproduce the problem here.
  • Switching the file format (between "Excel5" and "Excel2007") does not affect the outcome.
  • The following command-line script does not reproduce the problem in any environment. There must be some other option or variable that needs to be set to trigger the problem.

 

require_once 'PHPExcel.php';
$excel = new PHPExcel();
$worksheet = $excel->getActiveSheet();
$worksheet->getCell('A1')->setValue('C');

require_once 'PHPExcel/Writer/Excel5.php'; $writer = new PHPExcel_Writer_Excel5($excel); $writer->save("/tmp/test.xls");

 

Developer
Nov 19, 2009 at 3:44 AM

The problem could be a broken iconv_substr() function on those platforms.
http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=10876

jalex and totten, can you try with latest source code and post back the results
http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

If you have the mbstring extension enabled in PHP I think things will work with latest source code.

Nov 19, 2009 at 9:09 AM

koyama, that did it. Thanks.

(i downloaded change set 29450)

Regards,

Joel

Nov 19, 2009 at 2:20 PM

Wonderful! That did it.

Thanks for the quick reply.

 

Mar 22, 2010 at 3:16 PM
koyama wrote:

The problem could be a broken iconv_substr() function on those platforms.
http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=10876

jalex and totten, can you try with latest source code and post back the results
http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

If you have the mbstring extension enabled in PHP I think things will work with latest source code.

I came across this discussion for exactly the problem I was having.  However, when I tried the change set my app still didn't work - I tried 29450 recommended by Jalex and then the most recent one from this morning - neither made any difference.

Any advice or guidance would be greatly appreciated.

Developer
Mar 26, 2010 at 8:08 AM

@pm1318: 1) What PHP version are you running? 2) Do you have mbstring extension enabled?

Mar 26, 2010 at 10:01 AM
I have now resolved the issue. I did a clean install of PHPExcel on my live site and everything was fine after that. I did have a little trouble writing a file because gettempdir isn't in the version of PHP my host has installed but that is now fixed as well. Thanks for getting back to me about this.
Consider the environment before printing this email

Any views or opinions are solely those of the author and do not necessarily represent those of GfK NOP or any of its associated companies.
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient of this message, please do not read, copy, use or disclose this communication and notify the sender immediately. It should be noted that any review, retransmission, dissemination or other use of, or taking action in reliance upon, this information by persons or entities other than the intended recipient is prohibited.
Recipients are warned that GfK NOP cannot guarantee that attachments or enclosures are secure or error-free as information could be intercepted, corrupted, or contain viruses
GfK NOP Limited
Ludgate House
245 Blackfriars Road
London SE1 9UL
Place of registration:England and Wales Company number:2512551
Registered office: GfK NOP Limited, Ludgate House, 245 Blackfriars Road, London, SE1 9UL