TwigExcelBundle icon indicating copy to clipboard operation
TwigExcelBundle copied to clipboard

How to change number of decimals

Open thomas-negrault opened this issue 7 years ago • 2 comments

I have a cell with a formula and I would like to display only 2 decimals (if the value is 1.123456, I want to display 1.12).

In phpexcel, the following should work:

$sheet->getStyle('A1')->getNumberFormat()->setFormatCode('#,##0.00');
$sheet->getStyle("A1")->getNumberFormat()->setFormatCode('0.00'); 

I've tried:

{% xlscell 9 {style: {'numberFormat':{'formatCode':'#,##0.00','code':'#,##0.00'}}} %}
=J2 / 2
{% endxlscell %}

But it does not work..

What is the correct way to achieve this ?

For now I m using the Excel FIXED function but it is not optimal..

thomas-negrault avatar Dec 03 '17 16:12 thomas-negrault

Did you solved it? I got the same issue.

lackynasta avatar May 16 '18 12:05 lackynasta

Unfortunately no, I'm still using the FIXED function {% xlscell %}=FIXED({{ variable }},2){% endxlscell %}

thomas-negrault avatar May 16 '18 12:05 thomas-negrault