/** * Create a new sheet * @param string $title * @param callback|null $callback * @return LaravelExcelWriter */ public function sheet($title, $callback = null) { // Clone the active sheet $this->sheet = $this->excel->createSheet(null, $title); // If a parser was set, inject it if ($this->parser) { $this->sheet->setParser($this->parser); } // Set the sheet title $this->sheet->setTitle($title); // Set the default page setup $this->sheet->setDefaultPageSetup(); // Do the callback if ($callback instanceof Closure) { call_user_func($callback, $this->sheet); } // Autosize columns when no user didn't change anything about column sizing if (!$this->sheet->hasFixedSizeColumns()) { $this->sheet->setAutosize(Config::get('excel.export.autosize', false)); } // Parse the sheet $this->sheet->parsed(); return $this; }