Generates the binary excel data

@return string
@throws CakeException If the excel writer does not exist
9377
protected function output()
    {
        ob_start();

        $writer = PHPExcel_IOFactory::createWriter($this->PhpExcel, 'Excel2007');

        if (!isset($writer)) {
            throw new Exception('Excel writer not found');
        }

        $writer->setPreCalculateFormulas(false);
        $writer->setIncludeCharts(true);
        $writer->save('php://output');

        $output = ob_get_clean();

        return $output;
    }
957619
protected function getBinaryData() {
        if (is_dir($this->path)) {
            return '';
        }
        return [
            'contentType' => $this->getMime(), 
            'data' => $this->path,
            'filename' => basename($this->path)
        ];
    }
987122
public function getBinaryData()
    {
        $cmd = CatFileCommand::getInstance($this->getRepository())->content($this->getSubject(), $this->ref);

        return $this->getCaller()->execute($cmd)->getRawOutput();
    }
1099837
private function _writeMsoDrawingGroup()
	{
		// write the Escher stream if necessary
		if (isset($this->_escher)) {
			$writer = new PHPExcel_Writer_Excel5_Escher($this->_escher);
			$data = $writer->close();

			$record = 0x00EB;
			$length = strlen($data);
			$header = pack("vv",  $record, $length);

			return $this->writeData($header . $data);

		} else {
			return '';
		}
	}
1057984
public static function generate()
    {
        if (class_exists('O2System\Filesystem\System')) {
            $system = new \O2System\Filesystem\System();

            $metadata = [
                'machine'         => $system->getMachine(),
                'operatingSystem' => [
                    'name'    => $system->getName(),
                    'version' => $system->getVersion(),
                    'release' => $system->getRelease(),
                ],
                'hostname'        => $system->getHostname(),
                'cpuCores'        => $system->getCpuCores(),
                'macAddress'      => $system->getMacAddress(),
            ];
        } else {
            $metadata = [
                'machine'         => php_uname('m'),
                'operatingSystem' => [
                    'name'    => php_uname('s'),
                    'version' => php_uname('v'),
                    'release' => php_uname('r'),
                ],
                'hostname'        => php_uname('n'),
                'cpuCores'        => 1,
                'macAddress'      => implode(':', str_split(substr(md5('none'), 0, 12), 2)),
            ];
        }

        $uri = new Uri();

        $metadata[ 'domain' ] = $uri->getHost();
        $metadata[ 'ipAddress' ] = $_SERVER[ 'SERVER_ADDR' ];

        $string = json_encode($metadata);
        $string = md5($string);

        // Converts to UUID (Universally Unique Identifier)
        $parts[] = substr($string, 0, 8);
        $parts[] = substr($string, 8, 4);
        $parts[] = substr($string, 12, 4);
        $parts[] = substr($string, 16, 4);
        $parts[] = substr($string, 20, 12);

        $parts = array_map('strtoupper', $parts);

        return implode('-', $parts);
    }
948905
public function generateFile()
    {
        parent::generateFile();

        if (count($this->uses) > 0) {
            sort($this->uses);
            $uses = '';
            foreach ($this->uses as $use) {
                $uses .= 'use ' . $use . ';' . $this->getNewlineCharacter();
            }
            $this->file_content = str_replace('{{ uses }}', $uses, $this->file_content);
        } else {
            $this->file_content = str_replace('{{ uses }}', '', $this->file_content);
        }
        $this->file_content = str_replace('{{ className }}', $this->class_name, $this->file_content);

        return $this->file_content;
    }
980797
public function writeData(): array
    {
        $dataBuilder = new DataBuilder();
        $dataBuilder->setString('n', $this->name, '')
                    ->setArray('l', $this->labels->writeData(), null, [])
                    ->setArray('d', $this->descriptions->writeData(), null, [])
                    ->setArray('c', array_values(array_unique($this->craftingCategories)), 'strval', [])
                    ->setFloat('s', $this->craftingSpeed, 1.)
                    ->setInteger('i', $this->numberOfItemSlots, 0)
                    ->setInteger('f', $this->numberOfFluidInputSlots, 0)
                    ->setInteger('u', $this->numberOfFluidOutputSlots, 0)
                    ->setInteger('m', $this->numberOfModuleSlots, 0)
                    ->setFloat('e', $this->energyUsage, 0.)
                    ->setString('r', $this->energyUsageUnit, 'W')
                    ->setString('o', $this->iconHash, '');
        return $dataBuilder->getData();
    }
18498
public function output()
    {
        $data = [
            'classes' => [],
            'files'   => [],
        ];
        foreach ($this->processed as $type => $classes) {
            foreach ($classes as $name => $values) {
                $covered = $values['covered'];
                $total   = $values['total'];
                $pct     = (((int) $covered / (int) $total) * 100);

                $covered    = str_pad((string) $covered, 7, ' ', STR_PAD_LEFT);
                $total      = str_pad((string) $total, 5, ' ', STR_PAD_LEFT);
                $percentage = number_format($pct, 2).'%';
                $percentage = str_pad((string) $percentage, 10, ' ', STR_PAD_LEFT);

                if ($pct < 25) {
                    $covered    = $this->output->red($covered);
                    $total      = $this->output->red($total);
                    $percentage = $this->output->red($percentage);
                }

                if ($pct < 75) {
                    $covered    = $this->output->black->yellow($covered);
                    $total      = $this->output->black->yellow($total);
                    $percentage = $this->output->black->yellow($percentage);
                }

                if ($pct >= 75) {
                    $covered    = $this->output->green($covered);
                    $total      = $this->output->green($total);
                    $percentage = $this->output->green($percentage);
                }

                $data[$type][] = [$name, $covered, $total, $percentage];
            }
        }

        $out = [];
        if (count($data['classes']) > 0) {
            array_unshift($data['classes'], ['Class', 'Covered', 'Lines', 'Percentage']);

            $out[] = new Table($data['classes'], [
                'headerColor'     => Graphite::YELLOW,
                'columnSeparator' => '',
                'headerSeparator' => '',
                'cellPadding'     => 1,
            ]);
        }

        if (count($data['files']) > 0) {
            array_unshift($data['files'], ['File', 'Covered', 'Lines', 'Percentage']);

            $out[] = new Table($data['files'], [
                'headerColor'     => Graphite::YELLOW,
                'columnSeparator' => '',
                'headerSeparator' => '',
                'cellPadding'     => 1,
            ]);
        }

        return $this->output->render(implode("\n\n", $out));
    }
458036
public function generate(array $data): string
    {
        // Parse the flex form
        $flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class);
        $structureIdentifier = $flexFormTools->getDataStructureIdentifier($data['fieldConfig'], $data['tableName'], $data['fieldName'], []);
        $dataStructureArray = $flexFormTools->parseDataStructureByIdentifier($structureIdentifier);

        // Early return if flex couldn't be parsed
        if (!is_array($dataStructureArray)) {
            return '';
        }

        // Loop through this xml mess and call a generator for each found field
        $aFlexFieldData = $data;
        $resultArray = [];
        /** @var FieldGeneratorResolver $resolver */
        $resolver = GeneralUtility::makeInstance(FieldGeneratorResolver::class);
        if (isset($dataStructureArray['sheets']) && is_array($dataStructureArray['sheets'])) {
            foreach ($dataStructureArray['sheets'] as $sheetName => $sheetArray) {
                if (isset($sheetArray['ROOT']['el']) && is_array($sheetArray['ROOT']['el'])) {
                    foreach ($sheetArray['ROOT']['el'] as $sheetElementName => $sheetElementArray) {
                        // Casual field
                        if (isset($sheetElementArray['TCEforms']) && is_array($sheetElementArray['TCEforms'])) {
                            $aFlexFieldData['fieldName'] = $sheetElementName;
                            $aFlexFieldData['fieldConfig'] = $sheetElementArray['TCEforms'];
                            try {
                                $generator = $resolver->resolve($aFlexFieldData);
                                $flexFieldValue = $generator->generate($aFlexFieldData);
                                $resultArray['data'][$sheetName]['lDEF'][$sheetElementName]['vDEF'] = $flexFieldValue;
                            } catch (GeneratorNotFoundException $e) {
                                // No op if no matching generator was found
                            }
                            // Field handled, skip rest
                            continue;
                        }
                        // Container section
                        if (isset($sheetElementArray['type']) && $sheetElementArray['type'] === 'array'
                            && isset($sheetElementArray['section']) && $sheetElementArray['section'] == 1
                            && isset($sheetElementArray['el']) && is_array($sheetElementArray['el'])
                        ) {
                            $containerCounter = 0;
                            foreach ($sheetElementArray['el'] as $containerName => $containerElementArray) {
                                if (!isset($containerElementArray['el']) || !is_array($containerElementArray['el'])) {
                                    continue;
                                }
                                $containerCounter ++;
                                foreach ($containerElementArray['el'] as $containerSingleElementName => $containerSingleElementArray) {
                                    if (!isset($containerSingleElementArray['TCEforms']) || !is_array($containerSingleElementArray['TCEforms'])) {
                                        continue;
                                    }
                                    $aFlexFieldData['fieldName'] = $containerSingleElementName;
                                    $aFlexFieldData['fieldConfig'] = $containerSingleElementArray['TCEforms'];
                                    try {
                                        $generator = $resolver->resolve($aFlexFieldData);
                                        $flexFieldValue = $generator->generate($aFlexFieldData);
                                        $resultArray['data'][$sheetName]['lDEF']
                                            [$sheetElementName]['el']
                                            [$containerCounter][$containerName]['el']
                                            [$containerSingleElementName]['vDEF'] = $flexFieldValue;
                                    } catch (GeneratorNotFoundException $e) {
                                        // No op if no matching generator was found
                                    }
                                    // Field handled, skip rest
                                    continue;
                                }
                            }
                        }
                    }
                }
            }
        } elseif (isset($dataStructureArray['ROOT']['el']) && is_array($dataStructureArray['ROOT']['el'])) {
            foreach ($dataStructureArray['ROOT']['el'] as $elementName => $elementArray) {
                if (isset($elementArray['TCEforms']) && is_array($elementArray['TCEforms'])) {
                    $aFlexFieldData['fieldName'] = $elementName;
                    $aFlexFieldData['fieldConfig'] = $elementArray['TCEforms'];
                    try {
                        $generator = $resolver->resolve($aFlexFieldData);
                        $flexFieldValue = $generator->generate($aFlexFieldData);
                        $resultArray['data']['sDEF']['lDEF'][$elementName]['vDEF'] = $flexFieldValue;
                    } catch (GeneratorNotFoundException $e) {
                        // No op if no matching generator was found
                    }
                }
            }
        }

        // Get string representation of result via FlexFormTools
        $resultString = '';
        if (!empty($resultArray)) {
            $resultString = $flexFormTools->flexArray2Xml($resultArray, true);
        }

        return $resultString;
    }
353380
public static function generate ()
		{
			$data = random_bytes(16);

			$data[ 6 ] = chr(ord($data[ 6 ]) & 0x0f | 0x40); // set version to 0100
			$data[ 8 ] = chr(ord($data[ 8 ]) & 0x3f | 0x80); // set bits 6-7 to 10

			return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
		}
540721
protected function createExcel()
    {
        $this->phpexcel = new \PHPExcel();
        $tableNumber = 0;

        // Loop over all tables in document
        foreach($this->document->getTables() as $table){

            // Handle worksheets
            if ($tableNumber > 0) {
                $this->phpexcel->createSheet();
            }
            $excelWorksheet = $this->phpexcel->setActiveSheetIndex($tableNumber);
            if ($sheetTitle = $table->getAttribute('_excel-name')) {
                $excelWorksheet->setTitle($sheetTitle);
            }

            // Loop over all rows
            $rowNumber = 1;
            foreach($table->getRows() as $row){

                $excelWorksheet->getStyle($rowNumber.':'.$rowNumber)->applyFromArray($this->getRowStylesArray($row));
                $this->setDimensions($excelWorksheet, $excelWorksheet->getRowIterator($rowNumber)->current(), $row);

                // Loop over all cells in row
                $cellNumber = 0;
                foreach($row->getCells() as $cell){
                    $excelCellIndex = \PHPExcel_Cell::stringFromColumnIndex($cellNumber).$rowNumber;
                    
                    // Skip cells withing merge range
                    while ($excelWorksheet->getCell($excelCellIndex)->isInMergeRange()) {
                        $cellNumber++;
                        $excelCellIndex = \PHPExcel_Cell::stringFromColumnIndex($cellNumber).$rowNumber;
                    }
                    
                    // Set value
                    $explicitCellType = $cell->getAttribute('_excel-explicit');
                    if (!$explicitCellType) {
                        $explicitCellType = $row->getAttribute('_excel-explicit');
                    }

                    if ($explicitCellType) {
                        $excelWorksheet->setCellValueExplicit(
                            $excelCellIndex,
                            $this->changeValueEncoding($cell->getValue()),
                            $this->convertStaticPhpExcelConstantsFromStringsToConstants($explicitCellType)
                        );
                    } else {
                        $excelWorksheet->setCellValue(
                            $excelCellIndex,
                            $this->changeValueEncoding($cell->getValue())
                        );
                    }

                    // Merge cells
                    $colspan = $cell->getAttribute('colspan');
                    $rowspan = $cell->getAttribute('rowspan');

                    if ($colspan || $rowspan) {
                        if ($colspan) {$colspan = $colspan - 1;}
                        if ($rowspan) {$rowspan = $rowspan - 1;}
                        $mergeCellsTargetCellIndex = \PHPExcel_Cell::stringFromColumnIndex($cellNumber + $colspan).($rowNumber + $rowspan);
                        $excelWorksheet->mergeCells($excelCellIndex.':'.$mergeCellsTargetCellIndex);
                    }

                    // Set styles
                    $excelWorksheet->getStyle($excelCellIndex)->applyFromArray($this->getCellStylesArray($cell));
                    $this->setDimensions($excelWorksheet, $excelWorksheet->getCell($excelCellIndex), $cell);

                    $cellNumber++;
                }

                $rowNumber++;
            }

            $tableNumber++;
        }

        return $this->phpexcel;
    }
783119
public function generate()
    {
        if (false === file_exists($this->filename) || false === is_file($this->filename)) {
            throw new FileNotFoundException(sprintf('The file "%s" does not exist.', $this->filename));
        }

        $handle = fopen($this->filename, 'r');
        if (false === $handle) {
            throw new \RuntimeException(sprintf('Could not open file "%s".', $this->filename));
        }

        $header = $this->getCsv($handle);
        $parameters = [];
        while ($values = $this->getCsv($handle)) {
            $parameter = [];
            foreach ($values as $index => $value) {
                if (null === $this->parameters || true === in_array($header[$index], $this->parameters)) {
                    $parameter[$header[$index]] = $value;
                }
            }
            $parameters[] = $parameter;
        }

        return $parameters;
    }
575362
public function writeData(): array
    {
        $dataBuilder = new DataBuilder();
        $dataBuilder->setFloat('r', $this->getRed(), 1.)
                    ->setFloat('g', $this->getGreen(), 1.)
                    ->setFloat('b', $this->getBlue(), 1.)
                    ->setFloat('a', $this->getAlpha(), 1.);
        return $dataBuilder->getData();
    }
492638
public function generate()
    {
        /*write operation ->*/
        $writeTmp = fopen(
            $this->applicationDir.DS.'Controllers'.DS.$this->controller.'Controller'.EXT,
            'w'
        ) or die('Unable to generate controller');

        $contentAppendWith = '<?php '.PHP_EOL;

        fwrite($writeTmp, $contentAppendWith.$this->replacedContent);
        fclose($writeTmp);
        fclose($this->filePointer);
    }
227106
public function writeData(): array
    {
        $dataBuilder = new DataBuilder();
        $dataBuilder->setString('n', $this->name, '')
                    ->setString('m', $this->mainModName, '')
                    ->setArray('l', array_values(array_unique($this->loadedModNames)), 'strval', [])
                    ->setArray('o', array_values(array_unique($this->loadedOptionalModNames)), 'strval', [])
                    ->setArray('i', array_values(array_unique($this->itemHashes)), 'strval', [])
                    ->setArray('r', array_values(array_unique($this->recipeHashes)), 'strval', [])
                    ->setArray('a', array_values(array_unique($this->machineHashes)), 'strval', [])
                    ->setArray('c', array_values(array_unique($this->iconHashes)), 'strval', []);
        return $dataBuilder->getData();
    }
961015
public function generateExcel(): void
    {
        // Set Document Properties from Service values.
        $this->builder
             ->setCreator($this->getCreator())
             ->setLastModifiedBy($this->getCreator())
             ->setTitle($this->getTitle())
             ->setSubject($this->getTitle())
             ->setDescription($this->getDescription());

        if ($this->hasSheets()) {
            // Multiple sheets.
            $this->createSheets();
        } else {
            // Single sheet - these will be an array and a string.
            $headers     = $this->getHeaders();
            $reportArray = $this->getData();
            $sheetTitle  = $this->getSheetTitles();

            $this->builder->setActiveSheetIndex(0);

            $this->createSheet(
                $headers,
                $reportArray,
                $sheetTitle
            );
        }

        // Close the builder and write the file.
        $this->builder->closeAndWrite();

        return;
    }
866496
public function generate()
    {
        $this->fill();
        $content = [];
        foreach ($this->_cells as $item) {
            $content[] = $item->generate();
        }
        //return implode('', $content);
        return Html::tag('div', implode('', $content), $this->htmlOptions);
    }