PHP_XLSXWriter
PHP_XLSXWriter copied to clipboard
BUG: Sheet names containing a single quote won't be written correctly (auto_filter)
in the BuildworkbookXML function, the sheetname output (when auto_filter set) wraps the sheetname in single quotes but doesn't double up on any single quotes contained in the name. Also (and I may be wrong but I think that) the localSheetId needs to be incremented for each sheet,
$i=0;
foreach($this->sheets as $sheet_name=>$sheet) {
if ($sheet->auto_filter) {
$sheetname = (str_replace("'", "''", self::sanitize_sheetname($sheet->sheetname)); // special case ; single quotes need to be doubled up
$workbook_xml.='<definedName name="_xlnm._FilterDatabase" localSheetId="'.($i).'" hidden="1">\''.self::xmlspecialchars($sheetname).'\'!$A$1:' . self::xlsCell($sheet->row_count - 1, count($sheet->columns) - 1, true) . '</definedName>';
$i++;
}
}
When you consider implementing repeatCols/repeatRows/Print_Titles, they will also need to handle single quotes in the same way.