mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-27 20:30:05 +00:00
ADDED : Implement support for AutoFilter in PHPExcel_Writer_Excel5
This commit is contained in:
@@ -282,7 +282,7 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
|
||||
$escher = null;
|
||||
|
||||
// check if there are any shapes for this sheet
|
||||
if (count($sheet->getDrawingCollection()) == 0) {
|
||||
if (count($sheet->getDrawingCollection()) == 0 && $sheet->getAutoFilter() == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -322,6 +322,8 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
|
||||
|
||||
// set the shape type
|
||||
$spContainer->setSpType(0x004B);
|
||||
// set the shape flag
|
||||
$spContainer->setSpFlag(0x02);
|
||||
|
||||
// set the shape index (we combine 1-based sheet index and $countShapes to create unique shape index)
|
||||
$reducedSpId = $countShapes[$sheetIndex];
|
||||
@@ -356,6 +358,64 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
|
||||
|
||||
$spgrContainer->addChild($spContainer);
|
||||
}
|
||||
|
||||
// AutoFilters
|
||||
if($sheet->getAutoFilter() != ''){
|
||||
$rangeBounds = PHPExcel_Cell::rangeBoundaries($sheet->getAutoFilter());
|
||||
$iNumColStart = $rangeBounds[0][0];
|
||||
$iNumColEnd = $rangeBounds[1][0];
|
||||
|
||||
$iInc = $iNumColStart;
|
||||
while($iInc <= $iNumColEnd){
|
||||
++$countShapes[$sheetIndex];
|
||||
|
||||
// create an Drawing Object for the dropdown
|
||||
$oDrawing = new PHPExcel_Worksheet_BaseDrawing();
|
||||
// get the coordinates of drawing
|
||||
$cDrawing = PHPExcel_Cell::stringFromColumnIndex($iInc - 1) . $rangeBounds[0][1];
|
||||
$oDrawing->setCoordinates($cDrawing);
|
||||
$oDrawing->setWorksheet($sheet);
|
||||
|
||||
// add the shape
|
||||
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
|
||||
// set the shape type
|
||||
$spContainer->setSpType(0x00C9);
|
||||
// set the shape flag
|
||||
$spContainer->setSpFlag(0x01);
|
||||
|
||||
// set the shape index (we combine 1-based sheet index and $countShapes to create unique shape index)
|
||||
$reducedSpId = $countShapes[$sheetIndex];
|
||||
$spId = $reducedSpId
|
||||
| ($sheet->getParent()->getIndex($sheet) + 1) << 10;
|
||||
$spContainer->setSpId($spId);
|
||||
|
||||
// keep track of last reducedSpId
|
||||
$lastReducedSpId = $reducedSpId;
|
||||
|
||||
// keep track of last spId
|
||||
$lastSpId = $spId;
|
||||
|
||||
$spContainer->setOPT(0x007F, 0x01040104); // Protection -> fLockAgainstGrouping
|
||||
$spContainer->setOPT(0x00BF, 0x00080008); // Text -> fFitTextToShape
|
||||
$spContainer->setOPT(0x01BF, 0x00010000); // Fill Style -> fNoFillHitTest
|
||||
$spContainer->setOPT(0x01FF, 0x00080000); // Line Style -> fNoLineDrawDash
|
||||
$spContainer->setOPT(0x03BF, 0x000A0000); // Group Shape -> fPrint
|
||||
|
||||
// set coordinates and offsets, client anchor
|
||||
$endCoordinates = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::stringFromColumnIndex($iInc - 1));
|
||||
$endCoordinates .= $rangeBounds[0][1] + 1;
|
||||
|
||||
$spContainer->setStartCoordinates($cDrawing);
|
||||
$spContainer->setStartOffsetX(0);
|
||||
$spContainer->setStartOffsetY(0);
|
||||
$spContainer->setEndCoordinates($endCoordinates);
|
||||
$spContainer->setEndOffsetX(0);
|
||||
$spContainer->setEndOffsetY(0);
|
||||
|
||||
$spgrContainer->addChild($spContainer);
|
||||
$iInc++;
|
||||
}
|
||||
}
|
||||
|
||||
// identifier clusters, used for workbook Escher object
|
||||
$this->_IDCLs[$dgId] = $lastReducedSpId;
|
||||
|
||||
Reference in New Issue
Block a user