public function testFormulaWithLegacyFunction()
 {
     $formula = OpenFormulaParser::parse('of:=LEGACY.FINV(0.05;-1)', 0, ['test'], [0, 0, 0]);
     $this->assertEquals($formula->getElements(), ['Formula.FINV', '(', '0.05', ',', '-', '1', ')']);
 }
Beispiel #2
0
 function render_validation($id, array $address = null)
 {
     $sheets_name = $this->sheets_name();
     $validation = $this->validations[$id];
     if (array_key_exists('TABLE:CONDITION', $validation['attrs'])) {
         $temp_validation = str_replace('$', '', $validation['attrs']['TABLE:CONDITION']);
         $temp_validation_pieces = explode(":", $temp_validation, 2);
         $temp_validation = $temp_validation_pieces[1];
     } else {
         $temp_validation = "";
     }
     if (preg_match('/cell-content-is-in-list/', $temp_validation)) {
         // si validation de type "list de valeurs"
         preg_match_all("/cell-content-is-in-list\\((.*)\\)/", $temp_validation, $matches);
         $values = $matches[1][0];
         $temp_car = str_split($values);
         if ($temp_car[0] == '[') {
             // Range de valeurs
             $values = str_replace(array('[', ']'), '', $values);
             $values = explode(":", $values, 2);
             $head = OpenFormulaParser::referenceToCoordinates($values[0], 0, $sheets_name);
             $tail = OpenFormulaParser::referenceToCoordinates($values[1], $head[0], $sheets_name);
             $values = array();
             for ($i = 0; $i <= $tail[1] - $head[1]; $i++) {
                 for ($j = 0; $j <= $tail[2] - $head[2]; $j++) {
                     $tmp_sI = $head[0];
                     $tmp_rI = $head[1] + $i;
                     $tmp_cI = $head[2] + $j;
                     $tempcell = $this->getCell($tmp_sI, $tmp_rI, $tmp_cI);
                     if ($tempcell) {
                         $values[] = $tempcell->cell_get_value();
                     }
                 }
             }
         } else {
             $values = array();
             // Value list
             $validation_values = explode(";", $matches[1][0]);
             // Clean list
             foreach ($validation_values as $tmp_value) {
                 // Remove first and last chars, that are both "
                 $values[] = substr($tmp_value, 1, -1);
             }
         }
         // Set the list of potential values in the cell (adress)
         if (isset($address)) {
             $tmp_sI = $address[0];
             $tmp_rI = $address[1];
             $tmp_cI = $address[2];
         } else {
             $head = OpenFormulaParser::referenceToCoordinates($validation['attrs']['TABLE:BASE-CELL-ADDRESS'], 0, $sheets_name);
             $tmp_sI = $head[0];
             $tmp_rI = $head[1];
             $tmp_cI = $head[2];
         }
         $tempcell = $this->sheets[$tmp_sI]->row[$tmp_rI]->cells[$tmp_cI];
         $tempcell->setValueInList($values);
     }
 }