PHPOffice / PHPExcel

ARCHIVED
Other
11.46k stars 4.19k forks source link

Fields starting with "=" cause an error #486

Open tkulm opened 9 years ago

tkulm commented 9 years ago

I've opened a ticket in Maatwebsite/Laravel-Excel -project (https://github.com/Maatwebsite/Laravel-Excel/issues/284), but by the developer's recommendation I open it here too.

I'm exporting an Excel file from array that has cells with data like "=F00M..." without the quotes of course, but I get "PHPExcel_Calculation_Exception" -error. If there's a value like "=023..." the value in Excel is zero (obviously it should be "=023...").

In export-config I have 'calculate' => false because I don't want to calculate anything, just the data as it is in the array.

How can I export cells starting with "=" ?

The error seems to be related to calculation because this is the code part that gets returned by Laravel (even in the config the calculate is set to false):

throw new PHPExcel_Calculation_Exception(
$this->getWorksheet()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage()
);
MarkBaker commented 9 years ago

Unless you use setCellValueExplicit(), PHPExcel will treat any cell value that you set which begins with = as a formula; to set =FOOM as a string, you need to use setCellValueExplicit()