Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Trying to add a value with an unsupported type: NULL #713

Closed
Shelbyb opened this issue Dec 17, 2019 · 2 comments
Closed

Trying to add a value with an unsupported type: NULL #713

Shelbyb opened this issue Dec 17, 2019 · 2 comments

Comments

@Shelbyb
Copy link

Shelbyb commented Dec 17, 2019

I'm running into an issue where the writer is running into a fatal error Trying to add a value with an unsupported type: NULL

The bit of code that's failing is:

private function addRenderedRowsToSheetUpdated(array $rows, Writer $writer): void
    {
        $row = WriterEntityFactory::createRowFromArray($rows);

        /** Add the row to the writer */
        try {
        $writer->addRow($row);
        } catch (Exception $e) {

        }
    }

The array looks something like this:

object Box\Spout\Common\Entity\Cell(3) {
    protected value => array(9) (
        0 => string(13) "SOME STRING"
        1 => string(0) ""
        2 => string(0) ""
        3 => string(0) ""
        4 => string(0) ""
        5 => string(0) ""
        6 => string(12) "SOME STRING"
        7 => string(0) ""
        8 => string(1) "0"
    )
    protected type => integer 6
    protected style => object Box\Spout\Common\Entity\Style\Style(27) {
        private id => NULL
        private fontBold => bool FALSE
        private hasSetFontBold => bool FALSE
        private fontItalic => bool FALSE
        private hasSetFontItalic => bool FALSE
        private fontUnderline => bool FALSE
        private hasSetFontUnderline => bool FALSE
        private fontStrikethrough => bool FALSE
        private hasSetFontStrikethrough => bool FALSE
        private fontSize => integer 12
        private hasSetFontSize => bool TRUE
        private fontColor => string(6) "000000"
        private hasSetFontColor => bool FALSE
        private fontName => string(7) "Calibri"
        private hasSetFontName => bool TRUE
        private shouldApplyFont => bool TRUE
        private shouldApplyCellAlignment => bool FALSE
        private cellAlignment => NULL
        private hasSetCellAlignment => bool FALSE
        private shouldWrapText => bool FALSE
        private hasSetWrapText => bool FALSE
        private border => NULL
        private shouldApplyBorder => bool FALSE
        private backgroundColor => NULL
        private hasSetBackgroundColor => bool FALSE
        private format => NULL
        private hasSetFormat => bool FALSE
    }
}

Any ideas?

@adrilo
Copy link
Collaborator

adrilo commented Dec 20, 2019

Hi,

A cell should contain a single value. Here it contains an array... Hence the cell type being detected as ERROR.
You can create a Row from an array but not a Cell.

@adrilo adrilo closed this as completed Dec 20, 2019
@cmanley
Copy link

cmanley commented Mar 15, 2022

Actually, this should be re-opened as the error message is incorrect.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants