mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
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.
This commit is contained in:
parent
c15b286f88
commit
6357dd08b6
2 changed files with 6 additions and 3 deletions
|
@ -74,8 +74,8 @@ class MoodleExcelWorkbook {
|
||||||
* @param string $name Name of the sheet
|
* @param string $name Name of the sheet
|
||||||
* @return object MoodleExcelWorksheet
|
* @return object MoodleExcelWorksheet
|
||||||
*/
|
*/
|
||||||
function &add_worksheet($name = '') {
|
function add_worksheet($name = '') {
|
||||||
/// Create the Moodle Worksheet. Returns one pointer to it
|
// Create the Moodle Worksheet. Returns one pointer to it
|
||||||
$ws = new MoodleExcelWorksheet ($name, $this->pear_excel_workbook, $this->latin_output);
|
$ws = new MoodleExcelWorksheet ($name, $this->pear_excel_workbook, $this->latin_output);
|
||||||
return $ws;
|
return $ws;
|
||||||
}
|
}
|
||||||
|
@ -138,6 +138,9 @@ class MoodleExcelWorksheet {
|
||||||
*/
|
*/
|
||||||
function MoodleExcelWorksheet($name, &$workbook, $latin_output=false) {
|
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) {
|
if (strlen($name) > 31) {
|
||||||
// Excel does not seem able to cope with sheet names > 31 chars.
|
// Excel does not seem able to cope with sheet names > 31 chars.
|
||||||
// With $latin_output = false, it does not cope at all.
|
// With $latin_output = false, it does not cope at all.
|
||||||
|
|
|
@ -1495,7 +1495,7 @@ class table_spreadsheet_export_format_parent extends table_default_export_format
|
||||||
}
|
}
|
||||||
|
|
||||||
function start_table($sheettitle) {
|
function start_table($sheettitle) {
|
||||||
$this->worksheet =& $this->workbook->add_worksheet($sheettitle);
|
$this->worksheet = $this->workbook->add_worksheet($sheettitle);
|
||||||
$this->rownum=0;
|
$this->rownum=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue