public function generate($unlinkFlag = true) {
        // Determine which format we are using and call the appropriate method.
        if ($this->getReportType() === self::REPORT_EXCEL) {
            $this->generateExcel();

            // Output headers
            header('Pragma: public');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Content-Type: application/force-download');
            header('Content-Type: application/octet-stream');
            header('Content-Type: application/download');
            header('Content-Disposition: attachment;filename=' . $this->getFilename() . '.xlsx');
            header('Content-Transfer-Encoding: binary ');

            readfile($this->builder->getTempName());
            unlink($this->builder->getTempName());

            exit;
        }

        throw new UnexpectedValueException('Attempted to generate a report in an unsupported format.');
    }