Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 402 and 403]

(no description)

File Size: 240 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: SharedStringsManager  - X-Ref


__construct(string $filePath,Options $options,WorkbookRelationshipsManager $workbookRelationshipsManager,CachingStrategyFactoryInterface $cachingStrategyFactory)   X-Ref
No description

hasSharedStrings()   X-Ref
Returns whether the XLSX file contains a shared strings XML file.


extractSharedStrings()   X-Ref
Builds an in-memory array containing all the shared strings of the sheet.
All the strings are stored in a XML file, located at 'xl/sharedStrings.xml'.
It is then accessed by the sheet data, via the string index in the built table.

More documentation available here: http://msdn.microsoft.com/en-us/library/office/gg278314.aspx

The XML file can be really big with sheets containing a lot of data. That is why
we need to use a XML reader that provides streaming like the XMLReader library.


getStringAtIndex(int $sharedStringIndex)   X-Ref
Returns the shared string at the given index, using the previously chosen caching strategy.

param: int $sharedStringIndex Index of the shared string in the sharedStrings.xml file
return: string The shared string at the given index

cleanup()   X-Ref
Destroys the cache, freeing memory and removing any created artifacts.


getSharedStringsUniqueCount(XMLReader $xmlReader)   X-Ref
Returns the shared strings unique count, as specified in <sst> tag.

param: XMLReader $xmlReader XMLReader instance
return: null|int Number of unique shared strings in the sharedStrings.xml file

getBestSharedStringsCachingStrategy(?int $sharedStringsUniqueCount)   X-Ref
Returns the best shared strings caching strategy.

param: null|int $sharedStringsUniqueCount Number of unique shared strings (NULL if unknown)

processSharedStringsItem(XMLReader $xmlReader, int $sharedStringIndex)   X-Ref
Processes the shared strings item XML node which the given XML reader is positioned on.

param: XMLReader $xmlReader         XML Reader positioned on a "<si>" node
param: int       $sharedStringIndex Index of the processed shared strings item

shouldExtractTextNodeValue(DOMElement $textNode)   X-Ref
Not all text nodes' values must be extracted.
Some text nodes are part of a node describing the pronunciation for instance.
We'll only consider the nodes whose parents are "<si>" or "<r>".

param: DOMElement $textNode Text node to check
return: bool Whether the given text node's value must be extracted

shouldPreserveWhitespace(DOMElement $textNode)   X-Ref
If the text node has the attribute 'xml:space="preserve"', then preserve whitespace.

param: DOMElement $textNode The text node element (<t>) whose whitespace may be preserved
return: bool Whether whitespace should be preserved