Esempio n. 1
0
 protected function packFormula($formula)
 {
     if ($this->dataType === self::TYPE_USER_LIST) {
         $formula = str_replace(',', chr(0), $formula);
     }
     if ($formula != '') {
         $formula = $this->formulaParser->getReversePolish($formula);
     }
     return pack("vv", strlen($formula), 0x0) . $formula;
 }
Esempio n. 2
0
 /**
  * Write a formula to the specified row and column (zero indexed).
  * The textual representation of the formula is passed to the formula parser
  * which returns a packed binary string.
  *
  * @param integer $row     Zero indexed row
  * @param integer $col     Zero indexed column
  * @param string $formula The formula text string
  * @param mixed $format  The optional XF format
  * @throws \Exception
  */
 public function writeFormula($row, $col, $formula, $format = null)
 {
     $this->addCell($row, $col);
     // Strip the '=' or '@' sign at the beginning of the formula string
     if (in_array($formula[0], array('=', '@'), true)) {
         $formula = substr($formula, 1);
     } else {
         throw new \Exception('Invalid formula: should start with = or @');
     }
     $formula = $this->formulaParser->getReversePolish($formula);
     $this->appendRecord('Formula', array($row, $col, $formula, $format));
 }