I'm working with values like:
P.S.: placing apostrophe is okay but I didn't figured the way how to do it without showing it in Excel...
UPDATE1
I've implemented possible solution:
For values with spaces I can make similar logic as in 2(but add space in format).
What do you think about all of this, is it good idea at all?
0406440452
017649106486
040 28803190
I can't create mutual format for them...Seems like matching these values by separate regexes and applying specific format is only way to do it. What would you say?P.S.: placing apostrophe is okay but I didn't figured the way how to do it without showing it in Excel...
UPDATE1
I've implemented possible solution:
- I divided my values on 2 types: only numbers and numbers with spaces. Made appropriate regexes for them.
-
For only numbers I do:
$valueLength = strlen($value);
$numberFormat = '0';
for($i = 1; $i <= $valueLength;$i++) {
$numberFormat = $numberFormat . '#';
}
$cell->getStyle()->getNumberFormat()->setFormatCode($numberFormat);
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
$cell->getStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
As a result I recieve format like 0#########, depending from numbers amountFor values with spaces I can make similar logic as in 2(but add space in format).
What do you think about all of this, is it good idea at all?