Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-36845 excel export: don't output invalid sheet names.

We should clean any proposed worksheet name, to remove the characters
that Excel does not allow.
  • Loading branch information...
commit 832b653627ead7d624282e533a23f0e792fc3013 1 parent 2a0ec98
@timhunt timhunt authored
Showing with 6 additions and 3 deletions.
  1. +5 −2 lib/excellib.class.php
  2. +1 −1  lib/tablelib.php
View
7 lib/excellib.class.php
@@ -74,8 +74,8 @@ function MoodleExcelWorkbook($filename) {
* @param string $name Name of the sheet
* @return object MoodleExcelWorksheet
*/
- function &add_worksheet($name = '') {
- /// Create the Moodle Worksheet. Returns one pointer to it
+ function add_worksheet($name = '') {
+ // Create the Moodle Worksheet. Returns one pointer to it
$ws = new MoodleExcelWorksheet ($name, $this->pear_excel_workbook, $this->latin_output);
return $ws;
}
@@ -138,6 +138,9 @@ class MoodleExcelWorksheet {
*/
function MoodleExcelWorksheet($name, &$workbook, $latin_output=false) {
+ // Replace any characters in the name that Excel cannot cope with.
+ $name = strtr($name, '[]*/\?:', ' ');
+
if (strlen($name) > 31) {
// Excel does not seem able to cope with sheet names > 31 chars.
// With $latin_output = false, it does not cope at all.
View
2  lib/tablelib.php
@@ -1487,7 +1487,7 @@ function start_document($filename) {
}
function start_table($sheettitle) {
- $this->worksheet =& $this->workbook->add_worksheet($sheettitle);
+ $this->worksheet = $this->workbook->add_worksheet($sheettitle);
$this->rownum=0;
}
Please sign in to comment.
Something went wrong with that request. Please try again.