From ffb8ccc36209f62cca1816b3e7aa5b7ac3f32916 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Tue, 14 Feb 2012 01:03:40 +0000 Subject: [PATCH] Bugfix: Work item 15459 - Invalid cell coordinate in Autofilter for Excel2007 Writer git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@86455 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Writer/Excel2007/Worksheet.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php index 7e7d4df..754a365 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php +++ b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php @@ -725,7 +725,17 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ if ($pSheet->getAutoFilter() != '') { // autoFilter $objWriter->startElement('autoFilter'); - $objWriter->writeAttribute('ref', $pSheet->getAutoFilter()); + + // Strip any worksheet reference from the filter coordinates + $range = PHPExcel_Cell::splitRange($pSheet->getAutoFilter()); + $range = $range[0]; + // Strip any worksheet ref + if (strpos($range[0],'!') !== false) { + list($ws,$range[0]) = explode('!',$range[0]); + } + $range = implode(':', $range); + + $objWriter->writeAttribute('ref', str_replace('$','',$range)); $objWriter->endElement(); } }