/** * Share view with all sheets * @param string $view * @param array $data * @param array $mergeData * @return LaravelExcelWriter */ public function shareView($view, $data = array(), $mergeData = array()) { // Get the parser $this->getParser(); // Set the view inside the parser $this->parser->setView($view); $this->parser->setData($data); $this->parser->setMergeData($mergeData); return $this; }
/** * Add vars to the data array * @param string $key * @param bool|string $value * @param null $nullValue * @param bool|string $startCell * @param bool $strictNullComparison * @throws PHPExcel_Exception * @return void|$this */ protected function _addVars($key, $value = false, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) { // Add array of data if (is_array($key) || $key instanceof Collection) { // Set the data $this->data = $this->addData($key); // Create excel from array without a view if (!$this->parser) { return $this->createSheetFromArray($this->data, $nullValue, $startCell, $strictNullComparison); } } else { $this->data[$key] = $value; } // Set data to parser if ($this->parser) { $this->parser->setData($this->data); } }
public function stream_open($file, $mode, $options, &$opened_path) { $this->position = 0; $file = str_replace('view://', '', $file); $this->data = file_get_contents($file); if ($this->data === false) { $this->status = stat($file); return false; } else { $this->length = strlen($this->data); } $parser = new ViewParser(); /* if(!ini_get('short_open_tag')){ $search[] = '<? '; $search[] = '<?='; $replace[] = '<?php '; $replace[] = '<?php echo '; $this->data = str_replace($search, $replace, $this->data); } $this->data = str_replace('@$', '$this->', $this->data); $this->data = str_replace('parent->', 'getParent()->', $this->data); */ $this->data = $parser->parse($this->data); $this->status = array('mode' => 0100777, 'size' => strlen($this->data)); return true; }