Link to home
Start Free TrialLog in
Avatar of myyis
myyis

asked on

Format cell as text PHPExcel

I use the below to prepare my Excel sheet
 $objPHPExcel->getActiveSheet()->fromArray($datasource, null, 'A3');

The problem is  the values like 22.651 or 22,699 are formatted as numbers by default but I want to format the whole column  as text.

I tried this  but not worked  (it converts  22.651 to 22,651)
$objPHPExcel->getActiveSheet()->getStyle(bla,bla)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);

Here
stackoverflow.com/questions/12457610/reading-numbers-as-text-format-with-phpexcel
they suggest to use a binder but I want to use fromArray because I believe that it is much more faster.

So keeping fromArray function how can I set the format of specific cells to text (or better set format of all column to text)?
Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of myyis
myyis

ASKER

Hi,
I prefer not to change the whole code.
I prefer  keeping fromArray function and  set the format of specific cells to text (or better set format of all column to text) if it is possible.
Avatar of myyis

ASKER

Used the binder and worked. Thank you.