Index

XlsxPrinter

MMO\core\printers · 1 symbol · generated 30 Sep 2026

class

XlsxPrinter

XlsxPrinter.php:21

Flattens arbitrary rows of data (arrays, entities, nested structures) into a plain [row][column] => string grid suitable for Sheet cells -- e.g. what Document::addContent feeds a sheet with. A nested associative array is recursively flattened into parent/child-keyed columns; a plain list is joined inline (comma- or pipe-separated, see exportArray/exportObject) instead of spanning columns. A value already seen earlier in the same export (e.g. the same Entity referenced twice) is replaced by an Excel formula referencing the cell it was first rendered into (hash), instead of being repeated.

class MMO\core\printers\XlsxPrinter extends MMO\core\classes\aExporter
Namespace
MMO\core\printers
Extends
aExporter
XlsxPrinter::ExportLines([['name' => 'Marc', 'tags' => ['a', 'b']]]); // [['name' => 'Marc', 'tags' => 'a,b']]

Index

exportArray($value, $options)
exportEntity($value, $options)
exportInstance($value, $options)
ExportLines($lines, $options) staticFlatten each row (see the class docblock).
exportObject($value, $options)
exportUnitEnum($value, $options)
flatten($value, $options)Recursively flatten $value into a single-level column => string map: a nested associative array's keys are joined with the parent key via / (e.g.
hash($value, $options)NOTE: this used to always add 1 to $options['line'] (itself already the 1-based position within the DATA rows passed to ExportLines, i.e.
__construct($config)

Methods9

exportArray($value, $options)

XlsxPrinter.php:117
function exportArray(array $value, array $options = []): string
$valuearraya plain list (see flatten, which handles associative arrays separately).
$options = []array
returnsstringeach item exported and comma-joined into a single cell value.

ExportLines($lines, $options)

staticXlsxPrinter.php:40

Flatten each row (see the class docblock).

static function ExportLines(array $lines, MMO\core\interfaces\iOptions|array $options = []): array
$linesarrayeach an array, or an iArrayProperties (converted via toArray() first).
$options = []iOptions | array
returnsarrayeach row flattened to column => string value.

exportObject($value, $options)

XlsxPrinter.php:131
function exportObject(array $value, array $options = []): string
$valuearrayan associative array.
$options = []array
returnsstringeach "key: value" pair, | -joined into a single cell value.

exportUnitEnum($value, $options)

XlsxPrinter.php:145
function exportUnitEnum(object $value, array $options): string
$valueobjecta \UnitEnum/\BackedEnum case.
$optionsarray
returnsstringits backing value, or its case name for a pure (non-backed) enum.

flatten($value, $options)

XlsxPrinter.php:72

Recursively flatten $value into a single-level column => string map: a nested associative array's keys are joined with the parent key via / (e.g. meta/nested/x); anything else (including a plain list) is exported directly as one value (see exportArray).

protected function flatten(object|array $value, array &$options = []): array
$valueobject | array
$options = []array
returnsarray

hash($value, $options)

XlsxPrinter.php:107

NOTE: this used to always add 1 to $options['line'] (itself already the 1-based position within the DATA rows passed to ExportLines, i.e. not counting any header row Document::addContent may separately have written above them). That's the correct Excel row only when a header row precedes the data (its +1 shift happens to cancel out); with no header, it always pointed one row too far -- verified concretely: exporting 2 rows with no header, a repeated-object reference in row 2 produced the formula '=A2' (row 2, i.e. itself) instead of the correct '=A1' (row 1, where the object was actually rendered).

function hash(object $value, array $options = []): stringFixed by only adding that 1-row shift when $options['headers'] (the same option \MMO\core\documents\Document::addContent already passes through to [`ExportLines`](https://mmoframework.fr/documentation/mmo.core/php/printers/XlsxPrinter.md#xlsxprinter-exportlines)) says a header row exists.
$valueobject
$options = []array
returnsstringan Entity's title, or an Excel formula referencing the cell this value was already rendered into.
Inherited members (67)
ConstantsDeclared byDescription
ALERTiLogLevelAlert: Action must be taken immediately.
ALLiLogLevelMask for all
ALL_PLUSiLogLeveldebug everything
BACKTRACEiLogLevel
CRITICALiLogLevelCritical: Critical conditions.
DEBUGiLogLevelDebug: Detailed debug information.
DEEPiLogLeveldebug everything with arguments
EMERGENCYiLogLevelEmergency: System is unusable.
ERRORiLogLevelError: Runtime errors that do not require immediate action but should typically be logged and monitored.
ERROR_PLUSiLogLevelMask for all error
FATALiLogLevelMask for all fatal error
INFOiLogLevelInfo: Interesting events.
INFO_PLUSiLogLevelMask for all errors/warning/notices/info
MEMORYiLogLevelinclude backtrace object
NOTICEiLogLevelNotice: Normal but significant events.
NOTICE_PLUSiLogLevelMask for all errors/warning/notices/info
TRACEiLogLevelinclude backtrace as origins
WARNINGiLogLevelWarning: Exceptional occurrences that are not errors.
WARNING_PLUSiLogLevelMask for all errors and warnings
PropertiesDeclared byDescription
functionsaConverter
globalOptionsaConverter
verbosityaModule
MethodsDeclared byDescription
addOptions($type, $options)aConverterMerge $options into $type's existing options (via merge), rather than replacing them wholesale like setOptions.
alert($message, $context)aModuleAction must be taken immediately.
backtraces($message, $context)aModuleForce-log a message at INFO level together with a full stack trace/memory snapshot (iLogLevel::BACKTRACE), bypassing the verbosity mask entirely (any non-zero verbosity is enough to trigger it).
call($type, $value, $options)aConverterCall the function associated to a type
clear()aConverterRemove every registered type/function.
Configure($config)aModuleMerge $config into this module's configuration in the shared Configuration.
critical($message, $context)aModuleCritical conditions. No-op if CRITICAL is currently filtered out by the verbosity mask.
debug($message, $context)aModuleDetailed debug information.
debugName()aModuleHuman-readable identifier used as the default {origin} in this instance's log messages.
DefaultConfig()aModuleThe config a module starts from before anything loaded via Configuration is merged in.
emergency($message, $context)aModuleSystem is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask.
error($message, $context)aModuleRuntime errors that do not require immediate action but should typically be logged and monitored.
Export($value, $options, $type)aExporterExport any value, dispatching to the right converter based on its type (or the explicit $type).
exportEnum($value, $options)aExporterBuilt-in 'enum' converter.
ExportProperties($value, $options)aExporterExport an object exportInstance method
exportsProperty($prop, $value)aExporterWhether exportInstance exports $prop of $value: not a static property -- it is the class's, not $value's -- nor an uninitialized one, which has no value (the properties (array)$value holds).
getClassFunction($class)aConverterFind which registered type (a class or interface name) applies to $class: itself if directly registered, else the closest registered ancestor class or implemented interface.
getFunction($type)aConverter
getFunctions()aConverter
getOptions($type)aConverter
getType($value, $allowClass)aConverterNormalize $value's type into one of this converter's type names.
getVerbosity()aModule
hasType($type)aConverter
info($message, $context)aModuleInteresting events. No-op if INFO is currently filtered out by the verbosity mask.
Instantiate($config)aModule(Re)create the shared instance immediately, configured with $config merged into the class's existing config.
IsShared()aModule
log($level, $message, $context)aModuleLogs with an arbitrary level.
notice($message, $context)aModuleNormal but significant events.
offsetExists($key)aModule\ArrayAccess::offsetExists -- tells whether $key is a declared property at all, regardless of whether it is currently readable/writable through array access.
offsetGet($key)aModule\ArrayAccess::offsetGet -- reads a property directly, unless it has a #[Serialize(serialize: 'methodName')] attribute, in which case that zero-argument method is called instead (e.g.
offsetSet($key, $value)aModule\ArrayAccess::offsetSet -- sets a property directly, unless it has a #[Serialize(unserialize: 'methodName')] attribute, in which case that method is called with $value instead (e.g.
offsetUnset($key)aModule\ArrayAccess::offsetUnset -- equivalent to $module[$key] = null.
resetHash($value, $options)aExporterForget that $value was already seen, within the given $options['hashes'] tracking map: the next time $value is encountered in this same export, it is exported in full again instead of collapsing to…
serialize($path, $serializer)aModule\MMO\core\interfaces\iSerializable::serialize -- exports every property (via
setFunction($type, $fn, $options)aConverterSet a coercer
setFunctions($fns)aConverterRegister many functions at once, e.g.
setOptions($type, $options)aConverterReplace $type's options wholesale.
setVerbosity($verb)aModuleSet the current verbosity mask, replacing whatever it was before.
Shared()aModuleGet the shared instance, creating (and configuring) it on first call.
testVerbosity($level)aModuleTest whether a given level (or set of levels) is currently enabled by this instance's verbosity mask.
traitUnshare($serialize)aModuleRemove the shared instance, so the next Shared() call creates a fresh one.
unserialize($data, $path, $instances)aModule\MMO\core\interfaces\iSerializable::unserialize -- merges $data onto DefaultConfig, runs it through the (possibly overridden) constructor, then applies each resulting value to its property (via
Unshare($serialize)aModuleLike tSingleton::Unshare, but also disconnects this module's instance from every event it was listening to (via Event::DisconnectListeners) before dropping it.
warning($message, $context)aModuleExceptional occurrences that are not errors.
__invoke($value, $options, $type)aExporterThe actual export entry point (also what iExporter's $exporter($value) calling convention invokes).