class XlsxExporter in Webform XLSX export 8
Class XlsxExporter.
@package Drupal\webform_xlsx_export\Plugin\WebformExporter
Plugin annotation
@WebformExporter(
id = "xlsx",
label = @Translation("XLSX"),
description = @Translation("Exports results as an Office Open XML file."),
options = FALSE
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\webform\Plugin\WebformExporterBase implements WebformExporterInterface
- class \Drupal\webform\Plugin\WebformExporter\TabularBaseWebformExporter uses FileHandleTraitWebformExporter
- class \Drupal\webform_xlsx_export\Plugin\WebformExporter\XlsxExporter
- class \Drupal\webform\Plugin\WebformExporter\TabularBaseWebformExporter uses FileHandleTraitWebformExporter
- class \Drupal\webform\Plugin\WebformExporterBase implements WebformExporterInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of XlsxExporter
1 file declares its use of XlsxExporter
- XlsxExporterTest.php in tests/
src/ Unit/ XlsxExporterTest.php
File
- src/
Plugin/ WebformExporter/ XlsxExporter.php, line 22
Namespace
Drupal\webform_xlsx_export\Plugin\WebformExporterView source
class XlsxExporter extends TabularBaseWebformExporter {
/**
* PhpSpreadsheet object.
*
* @var \PhpOffice\PhpSpreadsheet\Spreadsheet
*/
private $xls;
/**
* {@inheritdoc}
*/
public function getFileExtension() {
return 'xlsx';
}
/**
* {@inheritdoc}
*/
public function createExport() {
$this->xls = new Spreadsheet();
}
/**
* {@inheritdoc}
*
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
*/
public function openExport() {
$this->xls = IOFactory::load($this
->getExportFilePath());
}
/**
* {@inheritdoc}
*
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function closeExport() {
IOFactory::createWriter($this->xls, "Xlsx")
->save($this
->getExportFilePath());
}
/**
* {@inheritdoc}
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
public function writeHeader() {
$sheet = $this->xls
->getActiveSheet();
foreach ($this
->buildHeader() as $column => $header) {
$sheet
->setCellValueByColumnAndRow($column + 1, 1, $header);
}
$sheet
->getStyle('A1:' . $sheet
->getHighestColumn() . '1')
->getFont()
->setBold(TRUE);
}
/**
* {@inheritdoc}
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
public function writeSubmission(WebformSubmissionInterface $webform_submission) {
$sheet = $this->xls
->getActiveSheet();
$row = $sheet
->getHighestRow();
foreach ($this
->buildRecord($webform_submission) as $column => $record) {
$sheet
->setCellValueByColumnAndRow($column + 1, $row + 1, $record);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FileHandleTraitWebformExporter:: |
protected | property | A file handler resource. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
TabularBaseWebformExporter:: |
protected | property | An associative array containing webform elements keyed by name. | |
TabularBaseWebformExporter:: |
protected | property | An associative array containing a webform's field definitions. | |
TabularBaseWebformExporter:: |
protected | function | Build export header using webform submission field definitions and webform element columns. | 1 |
TabularBaseWebformExporter:: |
protected | function | Build export record using a webform submission. | 2 |
TabularBaseWebformExporter:: |
protected | function | Get the field definition value from a webform submission entity. | |
TabularBaseWebformExporter:: |
protected | function | Get webform elements. | |
TabularBaseWebformExporter:: |
protected | function | Get a webform's field definitions. | |
WebformExporterBase:: |
protected | property | Cached archive object. | |
WebformExporterBase:: |
protected | property | The configuration factory. | |
WebformExporterBase:: |
protected | property | The webform element manager. | |
WebformExporterBase:: |
protected | property | The webform submission storage. | |
WebformExporterBase:: |
protected | property | The entity type manager. | |
WebformExporterBase:: |
protected | property | A logger instance. | |
WebformExporterBase:: |
protected | property | The webform token manager. | |
WebformExporterBase:: |
public | function |
Add file, directory, or content to exporter archive. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
protected | function | Add file, directory, or content to Tar archive. | |
WebformExporterBase:: |
protected | function | Add file, directory, or content to ZIP file. | |
WebformExporterBase:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
4 |
WebformExporterBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
1 |
WebformExporterBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
4 |
WebformExporterBase:: |
public | function |
Returns the results exporter description. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Get archive file extension for a webform. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Get archive file name for a webform. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Get archive file name and path for a webform. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Get archive file type. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Get export base file name without an extension. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Get the number of submissions to be exported with each batch. Overrides WebformExporterInterface:: |
1 |
WebformExporterBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
WebformExporterBase:: |
public | function |
Get export file name. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Get export file path. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Get export file temp directory. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
protected | function | Get the webform source entity whose submissions are being exported. | |
WebformExporterBase:: |
public | function |
Returns the results exporter status. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Get webform submission base file name. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
protected | function | Get the webform whose submissions are being exported. | |
WebformExporterBase:: |
public | function |
Determine if exporter can include uploaded files (in a zipped archive). Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Determine if exporter has options. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Determine if exporter generates an archive. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Checks if the exporter is excluded via webform.settings. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Returns the results exporter label. Overrides WebformExporterInterface:: |
|
WebformExporterBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
1 |
WebformExporterBase:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
|
WebformExporterBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
WebformExporterBase:: |
public | function |
Write footer to export. Overrides WebformExporterInterface:: |
1 |
WebformExporterBase:: |
public | function |
Constructs a WebformExporterBase object. Overrides PluginBase:: |
1 |
WebformExporterInterface:: |
constant | Tar archive. | ||
WebformExporterInterface:: |
constant | ZIP file. | ||
XlsxExporter:: |
private | property | PhpSpreadsheet object. | |
XlsxExporter:: |
public | function |
Overrides FileHandleTraitWebformExporter:: |
|
XlsxExporter:: |
public | function |
Overrides FileHandleTraitWebformExporter:: |
|
XlsxExporter:: |
public | function |
Get export file extension. Overrides WebformExporterBase:: |
|
XlsxExporter:: |
public | function |
Overrides FileHandleTraitWebformExporter:: |
|
XlsxExporter:: |
public | function |
Overrides WebformExporterBase:: |
|
XlsxExporter:: |
public | function |
Overrides WebformExporterBase:: |