Skip to content

Commit

Permalink
MDL-51603 dataformat_ods: Setting the sheet name
Browse files Browse the repository at this point in the history
Clearning according to Box\Spout\Writer\Common\Sheet::isNameValid
  • Loading branch information
David Monllao committed Apr 21, 2016
1 parent fef1114 commit 547d779
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions dataformat/ods/classes/writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 547d779

Please sign in to comment.