Execute an export to CSV command.

@param ExportCommand $exportCommand

@return string|Response
963552
public function executeExportCSVCommand(ExportCommand $exportCommand)
    {
        $translations = $this->getTranslations($exportCommand);
        /** @var CSVFileExporter $exporter */
        $exporter = $this->exporter->getExporterByExtension($exportCommand->getFormat());
        $exporter->setLocales($this->determineLocalesToImport($exportCommand));

        return $exporter->export($translations);
    }
550213
public function export($format = FilledFormExportFormat::JSON)
    {
        if (! $format instanceof FilledFormExportFormat) {
            $format = new FilledFormExportFormat($format);
        }

        return static::query($this->client, [$this->filled_form_id, self::EXPORT], ['format' => $format->getValue()]);
    }
107816
function export_class_instance($exportclass = null) {
        if (!is_null($exportclass)) {
            $this->started_output = true;
            $this->exportclass = $exportclass;
            $this->exportclass->table = $this;
        } else if (is_null($this->exportclass) && !empty($this->download)) {
            $this->exportclass = new table_dataformat_export_format($this, $this->download);
            if (!$this->exportclass->document_started()) {
                $this->exportclass->start_document($this->filename, $this->sheettitle);
            }
        }
        return $this->exportclass;
    }
928816
public function exportAction()
    {
        $request = $this->getRequest();
        if (!$request->isPost()) {
            $this->_redirect(self::ADMINHTML_SALES_ORDER_INDEX);
        }

        $orderIds = $this->getRequest()->getPost('order_ids', array());

        try {
            // Build the CSV and retrieve its path
            $filePath = Mage::getModel('australia/shipping_carrier_eparcel_export_csv')->exportOrders($orderIds);

            // Download the file
            $this->_prepareDownloadResponse(basename($filePath), file_get_contents($filePath));
        } catch (Exception $e) {
            Mage::getSingleton('core/session')->addError($e->getMessage());
            $this->_redirect(self::ADMINHTML_SALES_ORDER_INDEX);
        }
    }
758358
public function export()
    {
        $products = $this->repository->all();
        $fileName = strtolower(str_random()) . '.csv';
        $dirPath = storage_path('app/public/catalog');
        $this->directory($dirPath);
       
        $file = fopen($dirPath . '/' . $fileName, 'w');
        foreach ($products as $product) {
            fputcsv($file, $product->toArray());
        }
        fclose($file);
        
        return response()->download($dirPath . '/' . $fileName);
    }
1002431
protected function export()
    {
        $filesystem = new Filesystem();
        $handle = fopen($this->config['path'] . $this->prefix, "w");

        $checkPermissions = true;
        if (PHP_SAPI == 'cli') {
            $checkPermissions = false;
        }

        if (!$this->export->Init(
            $handle,
            $this->config["id"],
            false,
            true,
            $this->session["work_dir"],
            $this->session["file_dir"],
            $checkPermissions
        )
        ) {
            throw new ExportException('Failed to initialize export');
        }

        $this->export->DoNotDownloadCloudFiles();
        $this->export->StartExport();

        $this->export->StartExportMetadata();
        $this->export->ExportProperties($this->session["property_map"]);
        $this->export->ExportSections(
            $this->session["section_map"],
            time(),
            $this->config['interval'],
            $this->config["sections"],
            $this->session["property_map"]
        );
        $this->export->EndExportMetadata();

        $this->export->StartExportCatalog();
        $this->export->ExportElements(
            $this->session["property_map"],
            $this->session["section_map"],
            time(),
            $this->config['interval'],
            0,
            $this->config["elements"]
        );
        $this->export->EndExportCatalog();

        $this->export->ExportProductSets();
        $this->export->EndExport();

        fclose($handle);
        $filesystem->remove($this->config['path']);
        $filesystem->rename($this->config['path'] . $this->prefix, $this->config['path'], true);
    }
433314
public function export()
    {
        $path = $this->module->dataPath;
        FileHelper::createDirectory($path, $this->module->dirMode);

        $summary = $this->collectSummary();
        $dataFile = "$path/{$this->tag}.data";
        $data = [];
        $exceptions = [];
        foreach ($this->module->panels as $id => $panel) {
            try {
                $data[$id] = serialize($panel->save());
            } catch (\Exception $exception) {
                $exceptions[$id] = new FlattenException($exception);
            }
        }
        $data['summary'] = $summary;
        $data['exceptions'] = $exceptions;

        file_put_contents($dataFile, serialize($data));
        if ($this->module->fileMode !== null) {
            @chmod($dataFile, $this->module->fileMode);
        }

        $indexFile = "$path/index.data";
        $this->updateIndexFile($indexFile, $summary);
    }
221122
protected function export($export, string $fileName, string $writerType = null): TemporaryFile
    {
        $writerType = FileTypeDetector::detectStrict($fileName, $writerType);

        return $this->writer->export($export, $writerType);
    }
1311120
function handleExport(resultString) {
    if (resultString === "") {
        process.exit(500);
    }

    let targetPath = path.join(currentDir, argv.exportOutput);
    fs.writeFileSync(targetPath, resultString);
    console.log("Finished writing csv file to:", targetPath);
}
495302
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $logger = $this->getLogger();

        if (!$this->lock()) {
            $output->writeln('<comment>The command is already running in another process.</comment>');
            $logger->warning('Command is already running.');
        } else {
            try {
                $logger->info('Started export in command.');

                $orderVisitor = $this->getOrders();

                $this->getExporter()->exportOrders($orderVisitor, $this->getProgressBar($output, count($orderVisitor)));

                $logger->info('Finished export in command.');
            } catch (Exception $exc) {
                $logger->error('Stopped export in command.', ['exception' => $exc]);
            }
        }
    }
158409
public function export($formValues, $destination)
    {
        if (!isset($formValues['filename'])) {
            $msg = 'Missing filename for export using '.__CLASS__;
            common_Logger::w($msg);
            return Report::createFailure($msg);
        }

        $exportUri = isset($formValues['uri']) ? $formValues['uri'] : $formValues['classUri'];

        $report = Report::createSuccess();

        $itemService = taoItems_models_classes_ItemsService::singleton();

        $fileName = $formValues['filename'].'_'.time().'.zip';
        $path = tao_helpers_File::concat([$destination, $fileName]);
        if (!tao_helpers_File::securityCheck($path, true)) {
            throw new Exception('Unauthorized file name');
        }

        $zipArchive = new ZipArchive();
        if ($zipArchive->open($path, ZipArchive::CREATE) !== true) {
            throw new Exception('Unable to create archive at '.$path);
        }

        $item = new core_kernel_classes_Resource($exportUri);
        if ($itemService->hasItemModel($item, [OwiItemModel::ITEMMODEL_URI])) {
            $exporter = new OwiExporter($item, $zipArchive);
            $exporter->export();
        } else {
            throw new common_Exception('Tried to export non OWI ('.$item->getUri().') as OWI ');
        }

        $zipArchive->close();

        $report->setData($path);
        $report->setMessage(__('Resource(s) successfully exported.'));

        return $report;
    }
791496
private function importOwnBundlesTranslationFiles(ImportCommand $importCommand)
    {
        $imported = 0;
        $srcDir = $this->kernel->getProjectDir() . '/src';

        foreach ($this->kernel->getBundles() as $name => $bundle) {
            if (strpos($bundle->getPath(), $srcDir) !== false) {
                $importCommand->setDefaultBundle(strtolower($name));

                try {
                    $imported += $this->importSingleBundleTranslationFiles($importCommand);
                } catch (TranslationsNotFoundException $e) {
                    continue;
                }
            }
        }

        return $imported;
    }
651380
public function toJson($exportMode = self::EXPORT_ALL) {
    	if ($this->cacheService) {
    		// We store in cache the result array, along with the filename and the last date the file has been modified.
    		// Both must match for cache to be served.
    		$resultArray = $this->cacheService->get("mouf_class_json_".$this->getName()."/".$exportMode);
    		if ($resultArray) {
    			if ($resultArray['filename'] == $this->getFileName()) {
    				if ($resultArray['modificationdate'] == $this->getLastModificationDate()) {
    					return $resultArray['json'];
    				}
    			}	
    		}
    		$jsonArray = $this->performToJson($exportMode);
    		
    		$this->cacheService->set("mouf_class_json_".$this->getName()."/".$exportMode,
    				array(
    						'filename'=>$this->getFileName(),
    						'modificationdate'=>$this->getLastModificationDate(),
    						'json'=>$jsonArray
    					)
    				);
    		
    		return $jsonArray;
    	} else {
    		// TODO: move MoufReflectionHelper::classToJson inside this class.
    		return $this->performToJson($exportMode);
    	}
    }
1212085
public function addExportCsvFiltered(
		$text,
		$csv_file_name,
		$output_encoding = null,
		$delimiter = null,
		$include_bom = false
	) {
		return $this->addToExports(new Export\ExportCsv(
			$this,
			$text,
			$csv_file_name,
			true,
			$output_encoding,
			$delimiter,
			$include_bom
		));
	}
1059565
public function executeImportCommand(ImportCommand $importCommand)
    {
        if ($importCommand->getGlobals() || $importCommand->getDefaultBundle() === false || $importCommand->getDefaultBundle() === null) {
            return $this->importGlobalTranslationFiles($importCommand);
        }

        return $this->importBundleTranslationFiles($importCommand);
    }
589087
public function export()
    {
        $tableName = $this->db->quoteTableName($this->logTable);
        $sql = "INSERT INTO $tableName ([[level]], [[category]], [[log_time]], [[prefix]], [[message]])
                VALUES (:level, :category, :log_time, :prefix, :message)";
        $command = $this->db->createCommand($sql);
        foreach ($this->messages as $message) {
            list($text, $level, $category, $timestamp) = $message;
            if (!is_string($text)) {
                // exceptions may not be serializable if in the call stack somewhere is a Closure
                if ($text instanceof \Exception) {
                    $text = (string) $text;
                } else {
                    $text = VarDumper::export($text);
                }
            }
            $command->bindValues([
                ':level' => $level,
                ':category' => $category,
                ':log_time' => $timestamp,
                ':prefix' => $this->getMessagePrefix($message),
                ':message' => $text,
            ])->execute();
        }
    }
16105
public function exportFile( stdClass $params )
	{
		$this->_checkParams( $params, array( 'site', 'items' ) );
		$this->_setLocale( $params->site );
		$context = $this->_getContext();

		$items = (array) $params->items;
		$lang = ( property_exists( $params, 'lang' ) ) ? (array) $params->lang : array();

		$config = $context->getConfig();

		/** controller/extjs/catalog/export/text/default/exportdir
		 * Directory where exported files of catalog texts are stored
		 *
		 * All exported files are stored in this file system directory directory.
		 *
		 * The export directory must be relative to the "basedir" configuration
		 * option. If
		 *
		 *  /var/www/test
		 *
		 * is the configured base directory and the export directory should be
		 * located in
		 *
		 *  /var/www/test/htdocs/files/exports
		 *
		 * then the configuration for the export directory must be
		 *
		 *  htdocs/files/exports
		 *
		 * Avoid leading and trailing slashes for the export directory string!
		 *
		 * @param string Relative path in the file system
		 * @since 2014.03
		 * @category Developer
		 * @see controller/extjs/media/default/basedir
		 */
		$dir = $config->get( 'controller/extjs/catalog/export/text/default/exportdir', 'uploads' );

		/** controller/extjs/catalog/export/text/default/dirperms
		 * Directory permissions used when creating the directory if it doesn't exist
		 *
		 * The representation of the permissions is in octal notation (using 0-7)
		 * with a leading zero. The first number after the leading zero are the
		 * permissions for the web server creating the directory, the second is
		 * for the primary group of the web server and the last number represents
		 * the permissions for everyone else.
		 *
		 * You should use 0700 for the permissions as the web server needs
		 * to write into the new directory but the files shouldn't be publicall
		 * available. The group permissions are only important if you plan to
		 * retrieve the files directly via FTP or by other means because then
		 * you need to be able to read and manage those files. In this case use
		 * 0770 as permissions.
		 *
		 * A more detailed description of the meaning of the Unix file permission
		 * bits can be found in the Wikipedia article about
		 * {@link https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation file system permissions}
		 *
		 * @param integer Octal Unix permission representation
		 * @since 2014.03
		 * @category Developer
		 * @category User
		 */
		$perms = $config->get( 'controller/extjs/catalog/export/text/default/dirperms', 0700 );

		/** controller/extjs/catalog/export/text/default/downloaddir
		 * Directory where the exported files can be found through the web
		 *
		 * The exported files are stored in this directory directory.
		 *
		 * The download directory must be relative to the document root of your
		 * virtual host. If the document root is
		 *
		 *  /var/www/test/htdocs
		 *
		 * and the exported files will be in
		 *
		 *  /var/www/test/htdocs/files/exports
		 *
		 * then the configuration for the download directory must be
		 *
		 *  files/exports
		 *
		 * Avoid leading and trailing slashes for the export directory string!
		 *
		 * @param string Relative path in the URL
		 * @since 2014.03
		 * @category Developer
		 */
		$downloaddir = $config->get( 'controller/extjs/catalog/export/text/default/downloaddir', 'uploads' );

		$foldername = 'catalog-text-export_' . date('Y-m-d_H:i:s') . '_' . md5( time() . getmypid() );
		$tmpfolder = $dir . DIRECTORY_SEPARATOR . $foldername;

		if( is_dir( $dir ) === false && mkdir( $dir, $perms, true ) === false ) {
			throw new Controller_ExtJS_Exception( sprintf( 'Couldn\'t create directory "%1$s" with permissions "%2$o"', $dir, $perms ) );
		}

		$context->getLogger()->log( sprintf( 'Create export directory for catalog IDs: %1$s', implode( ',', $items ) ), MW_Logger_Abstract::DEBUG );

		$filename = $this->_exportData( $items, $lang, $tmpfolder );
		$downloadFile = $downloaddir . DIRECTORY_SEPARATOR . basename( $filename );

		return array(
			'file' => '<a href="'.$downloadFile.'">'.$context->getI18n()->dt( 'controller/extjs', 'Download' ).'</a>',
		);
	}