Collapse rows

Topics: Developer Forum
Oct 16, 2014 at 6:55 AM
Hello! How can I make it so that all groups were collapsed? Tried to use setCollapsed, but nothing came out. Save the document in Excel5 format.
Thanks!
// ~~~ Grouping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        $Group = 0;

        // First group
        for ($Row = 13; $Row < ($iLastRow - 1); $Row++) {
            $CellColor = $oSheet->getStyle("A" . $Row)->getFill()->getStartColor()->getRGB();
            if ($CellColor == "333399") {
                if ($Group <> 0) {
                    for ($RowG = $Group; $RowG <= ($Row - 1); $RowG++) {
                        $oSheet->getRowDimension($RowG)
                                ->setOutlineLevel(1)
                                ->setVisible(false);
                    }
                }
                $Group = $Row + 1;
            }
        }

        // Second group
        for ($Row = 13; $Row < ($iLastRow - 1); $Row++) {
            $CellColor = $oSheet->getStyle("A" . $Row)->getFill()->getStartColor()->getRGB();
            if ($CellColor == "333399") {
                if ($Group <> 0) {
                    for ($RowG = $Group; $RowG <= ($Row - 1); $RowG++) {
                        $oSheet->getRowDimension($RowG)
                                ->setOutlineLevel(2)
                                ->setVisible(false);
                    }
                }
                $Group = 0;
            } elseif ($CellColor == "9999FF") {
                if ($Group <> 0) {
                    for ($RowG = $Group; $RowG <= ($Row - 1); $RowG++) {
                        $oSheet->getRowDimension($RowG)
                                ->setOutlineLevel(2)
                                ->setVisible(false);
                    }
                }
                $Group = $Row + 1;
            }
        }

        // Third group
        for ($Row = 13; $Row < ($iLastRow - 1); $Row++) {
            $CellColor = $oSheet->getStyle("A" . $Row)->getFill()->getStartColor()->getRGB();
            if ($CellColor == "808080") {
                if ($Group <> 0) {
                    for ($RowG = $Group; $RowG <= ($Row - 1); $RowG++) {
                        $oSheet->getRowDimension($RowG)
                                ->setOutlineLevel(3)
                                ->setVisible(false);
                    }
                }
                $Group = $Row + 1;
            } elseif ($CellColor == "333399") {
                if ($Group <> 0) {
                    for ($RowG = $Group; $RowG <= ($Row - 1); $RowG++) {
                        $oSheet->getRowDimension($RowG)
                                ->setOutlineLevel(3)
                                ->setVisible(false);
                    }
                }
                $Group = 0;
            } elseif ($CellColor == "9999FF") {
                if ($Group <> 0) {
                    for ($RowG = $Group; $RowG <= ($Row - 1); $RowG++) {
                        $oSheet->getRowDimension($RowG)
                                ->setOutlineLevel(3)
                                ->setVisible(false);
                    }
                }
                $Group = 0;
            }
        }
        $oSheet->setShowSummaryBelow(false);