protected function applyValue(Worksheet $sheet, $col, $row, $value, $format, $styleArray = [])
    {
        if (0 == count($styleArray)) {
            $styleArray = $this->getDefaultStyleArrayForRow($row);
        }

        $style = new Style();
        $style->applyFromArray($styleArray);

        switch ($format) {
            case Format::DATE:
                if (!($value instanceof \DateTime)) {
                    $date = new \DateTime($value);
                } else {
                    $date = $value;
                }
                $value = Date::PHPToExcel($date);
                $style->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_YYYYMMDD2);
                break;

            case Format::DATETIME:
                if (!($value instanceof \DateTime)) {
                    $date = new \DateTime($value);
                } else {
                    $date = $value;
                }
                $value = Date::PHPToExcel($date);
                $style->getNumberFormat()->setFormatCode(self::FORMAT_DATETIME);
                break;

            case Format::FLOAT2:
                $style->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
                break;

            case Format::INTEGER:
                $style->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_NUMBER);
                break;

            case Format::MONEY:
            case Format::MONEY2:
                $style->getNumberFormat()->setFormatCode(self::FORMAT_EUR);
                break;

            case Format::PCT:
                $style->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_PERCENTAGE);
                break;

            case Format::PCT2:
                $style->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_PERCENTAGE_00);
                break;

            case Format::STRING:
                $style->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
                break;
        }

        $sheet->setCellValueByColumnAndRow($col, $row, $value);
        $sheet->duplicateStyle($style, Coordinate::stringFromColumnIndex($col).$row);
    }