mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-51603 dataformat_ods: Setting the sheet name
Clearning according to Box\Spout\Writer\Common\Sheet::isNameValid
This commit is contained in:
parent
fef111472c
commit
547d779012
@ -46,5 +46,26 @@ class writer extends \core\dataformat\spout_base {
|
||||
/** @var $spouttype */
|
||||
protected $spouttype = \Box\Spout\Common\Type::ODS;
|
||||
|
||||
/**
|
||||
* Set the title of the worksheet inside a spreadsheet
|
||||
*
|
||||
* For some formats this will be ignored.
|
||||
*
|
||||
* @param string $title
|
||||
*/
|
||||
public function set_sheettitle($title) {
|
||||
if (!$title) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Replace any characters in the name that ODS cannot cope with.
|
||||
$title = strtr(trim($title, "'"), '[]*/\?:', ' ');
|
||||
// Shorten the title if necessary.
|
||||
$title = \core_text::substr($title, 0, 31);
|
||||
// After the substr, we might now have a single quote on the end.
|
||||
$title = trim($title, "'");
|
||||
|
||||
$this->sheettitle = $title;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user