mongotop
mongotop

Reputation: 5774

add a plus sign next to positive value on excel report

I use this line to formate my excel cell

$objPHPExcel->getActiveSheet()->getStyle('D12')->getNumberFormat()->setFormatCode("0%");

if the value is negative, excel takes care of that and display the value with a negative sign next to it.
like : -12

How can I change my above code so that the value sign will shows up next to value even if the value is positive?

I mean if the value is positive I will see 12, but I want to change my code to be display +12

Upvotes: 3

Views: 1731

Answers (1)

Siddharth Rout
Siddharth Rout

Reputation: 149335

The format +0;-0;0 works in Excel (Shows + for positive, - for negative, 0 for 0)

So try this

setFormatCode("+0;-0;0")

Upvotes: 3

Related Questions