MDL-51603 dataformat_ods: Setting the sheet name

Clearning according to Box\Spout\Writer\Common\Sheet::isNameValid
This commit is contained in:
David Monllao 2016-04-21 15:57:22 +08:00
parent fef111472c
commit 547d779012

View File

@ -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;
}
}