Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ExecutionEngine/Util/StepConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum StepConfig: string
case CONFIG_FILTERS = 'filters';
case SETTINGS_DELIMITER = 'delimiter';
case SETTINGS_HEADER = 'header';
case SETTINGS_SHEET_NAME = 'sheetName';
case SETTINGS_HEADER_NO_HEADER = 'no_header';
case SETTINGS_HEADER_TITLE = 'title';
case SETTINGS_HEADER_NAME = 'name';
Expand Down
6 changes: 6 additions & 0 deletions src/Export/Attribute/Request/ExportDataRequestBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
type: 'string',
example: ';'
);
} else {

Check notice on line 47 in src/Export/Attribute/Request/ExportDataRequestBody.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Export/Attribute/Request/ExportDataRequestBody.php#L47

The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
$configProperties[] = new Property(
property: StepConfig::SETTINGS_SHEET_NAME->value,
type: 'string',
example: 'Sheet1'
);
}
parent::__construct(
content: new JsonContent(
Expand Down
6 changes: 6 additions & 0 deletions src/Export/Attribute/Request/ExportFolderDataRequestBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
type: 'string',
example: ';'
);
} else {

Check notice on line 48 in src/Export/Attribute/Request/ExportFolderDataRequestBody.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Export/Attribute/Request/ExportFolderDataRequestBody.php#L48

The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
$configProperties[] = new Property(
property: StepConfig::SETTINGS_SHEET_NAME->value,
type: 'string',
example: 'Sheet1'
);
}

parent::__construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function __invoke(XlsxCreationMessage $message): void
$columns = $this->extractConfigFieldFromJobStepConfig($message, StepConfig::CONFIG_COLUMNS->value);
$settings = $this->extractConfigFieldFromJobStepConfig($message, StepConfig::CONFIG_CONFIGURATION->value);
$headers = $settings[StepConfig::SETTINGS_HEADER->value] ?? StepConfig::SETTINGS_HEADER_NO_HEADER->value;
$sheetName = $settings[StepConfig::SETTINGS_SHEET_NAME->value] ?? null;

if (!isset($jobRun->getContext()[StepConfig::GRID_EXPORT_DATA->value])) {
$this->abort($this->getAbortData(
Expand All @@ -86,7 +87,9 @@ public function __invoke(XlsxCreationMessage $message): void
$headers !== StepConfig::SETTINGS_HEADER_NO_HEADER->value,
$headers === StepConfig::SETTINGS_HEADER_NAME
),
$user
$user,
null,
$sheetName
);
} catch (Exception $e) {
$this->abort($this->getAbortData(
Expand Down
6 changes: 4 additions & 2 deletions src/Export/Service/AbstractExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
GridExportData $gridExportData,
UserInterface $user,
?string $delimiter = null,
?string $sheetName = null,

Check notice on line 50 in src/Export/Service/AbstractExportService.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Export/Service/AbstractExportService.php#L50

Incorrect spacing between argument "$sheetName" and equals sign; expected 0 but found 1
): void {
$storage = $this->storageService->getTempStorage();

Expand All @@ -64,7 +65,7 @@
);
}

$this->generateExportFile($id, $storage, $headers, $gridExportData->getExportData(), $delimiter);
$this->generateExportFile($id, $storage, $headers, $gridExportData->getExportData(), $delimiter, $sheetName);
}

/**
Expand All @@ -89,7 +90,8 @@
FilesystemOperator $storage,
array $headers,
array $exportData,
string $delimiter
string $delimiter,
?string $sheetName = null,
): void;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Export/Service/CsvExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
FilesystemOperator $storage,
array $headers,
array $exportData,
string $delimiter
string $delimiter,
?string $sheetName = null,

Check notice on line 40 in src/Export/Service/CsvExportService.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Export/Service/CsvExportService.php#L40

Incorrect spacing between argument "$sheetName" and equals sign; expected 0 but found 1
): void {

$data = [];
Expand Down
1 change: 1 addition & 0 deletions src/Export/Service/ExportServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
GridExportData $gridExportData,
UserInterface $user,
?string $delimiter = null,
?string $sheetName = null,

Check notice on line 30 in src/Export/Service/ExportServiceInterface.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Export/Service/ExportServiceInterface.php#L30

Incorrect spacing between argument "$sheetName" and equals sign; expected 0 but found 1
): void;

/**
Expand Down
8 changes: 7 additions & 1 deletion src/Export/Service/XlsxExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,19 @@
FilesystemOperator $storage,
array $headers,
array $exportData,
string $delimiter
string $delimiter,
?string $sheetName = null,

Check notice on line 39 in src/Export/Service/XlsxExportService.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Export/Service/XlsxExportService.php#L39

Incorrect spacing between argument "$sheetName" and equals sign; expected 0 but found 1
): void {
$csvReader = new Csv();
$csvReader->setDelimiter($delimiter);
$csvReader->setSheetIndex(0);

$spreadsheet = $csvReader->loadSpreadsheetFromString($this->processData($delimiter, $headers, $exportData));

if ($sheetName !== null && $sheetName !== '') {
$spreadsheet->getActiveSheet()->setTitle($sheetName);
}

$writer = new Xlsx($spreadsheet);
$stream = fopen('php://temp', 'rb+');
$writer->save($stream);
Expand Down
Loading