$objPHPExcel->getActiveSheet()->fromArray($dataArray,null,"A2")
I've the above line of code. The problem is, I am not good at iterating and I want all the cell values to be set as STRING so as to avoid automated modifications of texts leading zeros.
P.S. In Addition, code for setting as STRING for selective columns will be appreciated.
Thanks!
When you set cell values individually, you have the option of setting the datatype explicitly, but when you use the
fromArray()
method, you don't have this option.However, by default, PHP uses a default value binder to identify datatypes from the values passed, and set the cell datatype accordingly. This default behaviour is defined in a class
/PHPExcel/Cell/DefaultValueBinder.php
.So you can create your own value binder, as described in the PHPExcel Documentation, that would set every value as a string datatype.
Something like: