erouel/php-excel

Formulas?

Closed this issue · 4 comments

I can't see a way to pass formulas to excel. Without this, it is of very
limited use.

Original issue reported on code.google.com by pilavd...@gmail.com on 21 Mar 2007 at 7:35

Jepp, this is true. I am already working on allowing at least the most simple
mathematic operations. Stay tuned for an update beginning of next week. 
Currently
it's really just a data dump into an xml file.

Original comment by oliver.s...@gmail.com on 22 Mar 2007 at 8:49

I just took a look into the formula thing and I am quite impressed how excel 
deals
with this. However, I am not sure how to implement such a feature. Adding 
formular
usage to the class will definitely make it lose it's "lightweight".

Original comment by oliver.s...@gmail.com on 10 Sep 2009 at 3:48

  • Changed state: Accepted
Hello!

For a personal project I made this little modification to AddRow method to put 
a simple formula at worksheet

if (preg_match('/^=/', $v)) {
        $type = 'Number';
        //<Cell ss:StyleID="s21" ss:Formula="=100-(RC[-2]*100/RC[-3])"><Data ss:Type="Number"></Data></Cell>
        $cells .= "<Cell ss:Formula=\"$v\"><Data ss:Type=\"$type\"></Data></Cell>\n";
}

OBS: RC it's cells offset from current position
I know this resolv my own issue and it's far from being a global solution , but 
may could help.

Bye!

Original comment by perr...@gmail.com on 27 Sep 2009 at 10:12

I've checked various possibilities to insert formulas into the excel/XML 
document. Quite easy, when parsing the 
equal sign "=" at the beginning of the string. However, I decided, not to 
support formulas in version 1 releases 
of the library.

Introducing formulas insertion needs more than the creation of an array for 
dumping into excel. So a preparation 
wrapper would be the best way to enter single cells, add up to rows and finally 
to columns. This exceeds the idea 
of a simple dump library.

Original comment by oliver.s...@gmail.com on 29 Sep 2009 at 6:37

  • Changed state: WontFix