I'm trying to figure out how I can insert a hyphen list into a cell with phpexcel like this:
-Value A
-Value B
I tried it with following snippet:
// input value can be something else
$value = "-ValueA\n-Value B";
if (strpos($value, '-') === 0 || strpos($value, '=') === 0) {
$value = '\'' . $value;
$cell->setValueExplicit($value, \PHPExcel_Cell_DataType::TYPE_FORMULA);
} else {
$cell->setValueExplicit($value, \PHPExcel_Cell_DataType::TYPE_STRING);
}
$cell->getStyle()->getAlignment()->setWrapText(true);
But with this code phpexcel adds an equal sign (=) before the string.
When I skip the part to escape the hyphen sign (-) excel shows the apostroph in the cell like:
'-Value A
-Value B
Until I click into and out the cell.
What can I do to escape the hyphen correctly? I'm using PHPExcel 1.8.1 with PHP 5.6.8. Creating an xlsx file and opening it with Excel 2007.