nozavroni / csvelte

🕺🏻 CSV and Tabular Data library for PHP
http://phpcsv.com/
Other
6 stars 0 forks source link

Dynamic columns #76

Open deni-zen opened 8 years ago

deni-zen commented 8 years ago

Although this is by no means a priority, it would be nice to be able to specify dynamic columns that work something like formulas in Excel and other spreadsheet applications. Perhaps even write the feature in such a way that it attempts to recognize formulas and convert them to dynamic columns within CSVelte.

<?php
$col = new CSVelte\Table\Column();
$col->addRule(function($current, $last, $init){
    $val = $last ?: $init;
    return ($val + $current); // Fibonacci?
});
$col->addRule(function($current, $last, $init){
    return '[' . $current . ']';
});