Error when using links

Topics: Developer Forum
Nov 28, 2012 at 4:05 AM
Edited Nov 28, 2012 at 4:05 AM

Error: WorkSheet_2!A8 -> Formula Error: An unexpected error occured



	->setCellValueExplicit('A8', "=$'WorkSheet_1'.A7", PHPExcel_Cell_DataType::TYPE_FORMULA);

What to do?

Nov 28, 2012 at 6:07 AM
Hum... What is this formula is supposed to achieve?

I do not claim to know all the arcana of Excel but this tells me nothing... And if PHPExcel is'nt more inspired, he complains.
Nov 28, 2012 at 8:37 AM

Well.. What is necessary to do: we have one WorkSheet, where is written some Cells, necessary to create some links on another WorkSheet.

Like this:

            ->setCellValue('A1', 'Hello')
            ->setCellValue('B1', 'world!');


            ->setCellValueExplicit('A1', "='Ws1'.A1&'Ws1'.B1", PHPExcel_Cell_DataType::TYPE_FORMULA);

Nov 28, 2012 at 10:17 AM

Ok ( the second sheet display 'Helloworld!' for A1).

The correct formula is ='Ws1'!A1&'Ws1'!B1

Use the "!", not the "." between sheet name and cell coordinate. If you need "absolute" address (the '$' in front on your first formula) : 'Ws1'!$A$1, if the '$' is for substitution : "='$Sheetname'!A1&'$Sheetname'!B1"

Nov 29, 2012 at 3:47 AM

Thx! That's working!