Dash ('-') like cell value

Topics: Developer Forum, Project Management Forum, User Forum
Nov 4, 2009 at 12:38 PM

Hi all.

I having a problem when I try to put a dash ('-') like cell value. Here you the pice of my source code where I do that.

...
if ( _empty($value) ) {
   $objPHPExcel->getActiveSheet()->setCellValue($row, '-');
} else {
...

where $row is a value like 'A1'.

When I open the Excel file generated I found, in the cell, a zero ('0') and not the dash I expected.

I have tried also this solution:

...
if ( _empty($value) ) {
   $objPHPExcel->getActiveSheet()->setCellValue($row, "-");
   $objPHPExcel->getActiveSheet()->getStyle($row)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
} else {
...

but obtain the same result above.

Someone had the same problem or have solved it?

Thank's,

Alex.

Coordinator
Nov 4, 2009 at 12:47 PM

Try

$objPHPExcel->getActiveSheet()->setCellValueExplicit($row, '-',PHPExcel_Cell_DataType::TYPE_STRING);

 

Nov 4, 2009 at 12:55 PM

Thank's Mark.

This work for me. GREAT!

And thank you for your job. It's very important. :)

 

Developer
Nov 4, 2009 at 11:44 PM

MarkBaker's solutions is good, but this is still a bug in PHPExcel. The single hyphen is seen as a minus sign which is wrong.

Fixing this here:

http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=10884