Formular insertion

Topics: Developer Forum
Mar 13, 2013 at 11:49 AM
Edited Mar 13, 2013 at 12:14 PM
Inserting a formula like this "=SUM(C4:C34)" by setCellValue("C35","=SUM(C4:C34)") worked as expected. But in my case I need to insert a formula with column and row instead of excel-type coordinates.
Like this:
I've no idea how to create the formula because the nuber of columns and rows depend on database values I'm looping through.
Mar 14, 2013 at 10:22 AM
The PHPExcel calculation engine doesn't support R1C1 format cell references in formulae, but you can still write a formula using that syntax and save as long as you disable preCalculateFormulae in the writer before saving. Part of the work I'm doing this year is rewriting the calculation engine so that it will (among other features) support R1C1 format cell references

But can't you simply use the built-in PHPExcel_Cell::stringFromColumnIndex() method to get the column letter, and then concatenate that with the row number to create your range as a string, then just use that.
Mar 16, 2013 at 9:55 AM
thank you for your fast and helpful answer to my post.
PHPExcel_Cell::stringFromColumnIndex() method
was exactly what I was looking for.