Forum


Replies: 4   Views: 140
Cellstyles display issue using addtable
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpxlsx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpxlsx version and check the Documentation available.

Posted by Elisee9571  · 28-02-2025 - 09:27

$xlsx = new CreateXlsx();

        $cellStyles = array(
            'type' => 'general',
            'backgroundColor' => 'D9E1F2',
        );

        $contents = array(
            array(
                array(
                    'text' => '10',
                    'cellStyles' => $cellStyles,
                ),
                array(
                    'text' => '50',
                    'cellStyles' => $cellStyles,
                ),
                array(
                    'text' => '20',
                    'cellStyles' => $cellStyles,
                ),
            ),
            array(
                array(
                    'text' => '20',
                    'cellStyles' => $cellStyles,
                ),
                array(
                    'text' => '25.5',
                    'cellStyles' => $cellStyles,
                ),
                array(
                    'text' => '31',
                    'cellStyles' => $cellStyles,
                ),
            ),
        );
        
        $options = array(
            'columnNames' => array(
                array(
                    'text' => 'Values 1',
                    'bold' => true,
                    'color' => 'FFFFFF',
                    'cellStyles' => array(
                        'backgroundColor' => '4472C4',
                    ),
                ),
                array(
                    'text' => 'Values 2',
                    'bold' => true,
                    'color' => 'FFFFFF',
                    'cellStyles' => array(
                        'backgroundColor' => '4472C4',
                    ),
                ),
                array(
                    'text' => 'Values 3',
                    'bold' => true,
                    'color' => 'FFFFFF',
                    'cellStyles' => array(
                        'backgroundColor' => '4472C4',
                    ),
                ),
            ),
        );

        $xlsx->addTable($contents, 'B3', array(), $options);

        $fileName = Uuid::v7() . '.xlsx';
        $file = $this->getParameter('documents_dir') . '/' . $fileName;

        $xlsx->saveXlsx($file);

The issue i'm facing is related to CellStyles, everything that's related to the Contents CellStyles doesn't work. It's not displaying. More specifically, everything is working besides that, which means everything in the variable $options is working perfectly. The parameter cellStyles in the variable $contents isn't displaying.