Vendor/phpspreadsheet/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, $pCellAddress, array $pFlippedStringTable)
    {
        // Cell
        $pCell = $pSheet->getCell($pCellAddress);
        $objWriter->startElement('c');
        $objWriter->writeAttribute('r', $pCellAddress);

        // Sheet styles
        if ($pCell->getXfIndex() != '') {
            $objWriter->writeAttribute('s', $pCell->getXfIndex());
        }

        // If cell value is supplied, write cell value
        $cellValue = $pCell->getValue();
        if (is_object($cellValue) || $cellValue !== '') {
            // Map type
            $mappedType = $pCell->getDataType();

            // Write data type depending on its type
            switch (strtolower($mappedType)) {
                case 'inlinestr':    // Inline string
                case 's':            // String
                case 'b':            // Boolean
                    $objWriter->writeAttribute('t', $mappedType);

                    break;
                case 'f':            // Formula
                    $calculatedValue = ($this->getParentWriter()->getPreCalculateFormulas()) ?
                        $pCell->getCalculatedValue() : $cellValue;
                    if (is_string($calculatedValue)) {
                        $objWriter->writeAttribute('t', 'str');
                    } elseif (is_bool($calculatedValue)) {
                        $objWriter->writeAttribute('t', 'b');
                    }

                    break;
                case 'e':            // Error
                    $objWriter->writeAttribute('t', $mappedType);
            }

            // Write data depending on its type
            switch (strtolower($mappedType)) {
                case 'inlinestr':    // Inline string
                    if (!$cellValue instanceof RichText) {
                        $objWriter->writeElement('t', StringHelper::controlCharacterPHP2OOXML(htmlspecialchars($cellValue)));
                    } elseif ($cellValue instanceof RichText) {
                        $objWriter->startElement('is');
                        $this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $cellValue);
                        $objWriter->endElement();
                    }

                    break;
                case 's':            // String
                    if (!$cellValue instanceof RichText) {
                        if (isset($pFlippedStringTable[$cellValue])) {
                            $objWriter->writeElement('v', $pFlippedStringTable[$cellValue]);
                        }
                    } elseif ($cellValue instanceof RichText) {
                        $objWriter->writeElement('v', $pFlippedStringTable[$cellValue->getHashCode()]);
                    }

                    break;
                case 'f':            // Formula
                    $attributes = $pCell->getFormulaAttributes();
                    if ($attributes['t'] == 'array') {
                        $objWriter->startElement('f');
                        $objWriter->writeAttribute('t', 'array');
                        $objWriter->writeAttribute('ref', $pCellAddress);
                        $objWriter->writeAttribute('aca', '1');
                        $objWriter->writeAttribute('ca', '1');
                        $objWriter->text(substr($cellValue, 1));
                        $objWriter->endElement();
                    } else {
                        $objWriter->writeElement('f', substr($cellValue, 1));
                    }
                    if ($this->getParentWriter()->getOffice2003Compatibility() === false) {
                        if ($this->getParentWriter()->getPreCalculateFormulas()) {
                            if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) != '#') {
                                $objWriter->writeElement('v', StringHelper::formatNumber($calculatedValue));
                            } else {
                                $objWriter->writeElement('v', '0');
                            }
                        } else {
                            $objWriter->writeElement('v', '0');
                        }
                    }

                    break;
                case 'n':            // Numeric
                    // force point as decimal separator in case current locale uses comma
                    $objWriter->writeElement('v', str_replace(',', '.', $cellValue));

                    break;
                case 'b':            // Boolean
                    $objWriter->writeElement('v', ($cellValue ? '1' : '0'));

                    break;
                case 'e':            // Error
                    if (substr($cellValue, 0, 1) == '=') {
                        $objWriter->writeElement('f', substr($cellValue, 1));
                        $objWriter->writeElement('v', substr($cellValue, 1));
                    } else {
                        $objWriter->writeElement('v', $cellValue);
                    }

                    break;
            }
        }

        $objWriter->endElement();
    }
private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, $pCellAddress, array $pFlippedStringTable)
    {
        // Cell
        $pCell = $pSheet->getCell($pCellAddress);
        $objWriter->startElement('c');
        $objWriter->writeAttribute('r', $pCellAddress);

        // Sheet styles
        if ($pCell->getXfIndex() != '') {
            $objWriter->writeAttribute('s', $pCell->getXfIndex());
        }

        // If cell value is supplied, write cell value
        $cellValue = $pCell->getValue();
        if (is_object($cellValue) || $cellValue !== '') {
            // Map type
            $mappedType = $pCell->getDataType();

            // Write data type depending on its type
            switch (strtolower($mappedType)) {
                case 'inlinestr':    // Inline string
                case 's':            // String
                case 'b':            // Boolean
                    $objWriter->writeAttribute('t', $mappedType);

                    break;
                case 'f':            // Formula
                    $calculatedValue = ($this->getParentWriter()->getPreCalculateFormulas()) ?
                        $pCell->getCalculatedValue() : $cellValue;
                    if (is_string($calculatedValue)) {
                        $objWriter->writeAttribute('t', 'str');
                    } elseif (is_bool($calculatedValue)) {
                        $objWriter->writeAttribute('t', 'b');
                    }

                    break;
                case 'e':            // Error
                    $objWriter->writeAttribute('t', $mappedType);
            }

            // Write data depending on its type
            switch (strtolower($mappedType)) {
                case 'inlinestr':    // Inline string
                    if (!$cellValue instanceof RichText) {
                        $objWriter->writeElement('t', StringHelper::controlCharacterPHP2OOXML(htmlspecialchars($cellValue)));
                    } elseif ($cellValue instanceof RichText) {
                        $objWriter->startElement('is');
                        $this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $cellValue);
                        $objWriter->endElement();
                    }

                    break;
                case 's':            // String
                    if (!$cellValue instanceof RichText) {
                        if (isset($pFlippedStringTable[$cellValue])) {
                            $objWriter->writeElement('v', $pFlippedStringTable[$cellValue]);
                        }
                    } elseif ($cellValue instanceof RichText) {
                        $objWriter->writeElement('v', $pFlippedStringTable[$cellValue->getHashCode()]);
                    }

                    break;
                case 'f':            // Formula
                    $attributes = $pCell->getFormulaAttributes();
                    if ($attributes['t'] == 'array') {
                        $objWriter->startElement('f');
                        $objWriter->writeAttribute('t', 'array');
                        $objWriter->writeAttribute('ref', $pCellAddress);
                        $objWriter->writeAttribute('aca', '1');
                        $objWriter->writeAttribute('ca', '1');
                        $objWriter->text(substr($cellValue, 1));
                        $objWriter->endElement();
                    } else {
                        $objWriter->writeElement('f', substr($cellValue, 1));
                    }
                    if ($this->getParentWriter()->getOffice2003Compatibility() === false) {
                        if ($this->getParentWriter()->getPreCalculateFormulas()) {
                            if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) != '#') {
                                $objWriter->writeElement('v', StringHelper::formatNumber($calculatedValue));
                            } else {
                                $objWriter->writeElement('v', '0');
                            }
                        } else {
                            $objWriter->writeElement('v', '0');
                        }
                    }

                    break;
                case 'n':            // Numeric
                    // force point as decimal separator in case current locale uses comma
                    $objWriter->writeElement('v', str_replace(',', '.', $cellValue));

                    break;
                case 'b':            // Boolean
                    $objWriter->writeElement('v', ($cellValue ? '1' : '0'));

                    break;
                case 'e':            // Error
                    if (substr($cellValue, 0, 1) == '=') {
                        $objWriter->writeElement('f', substr($cellValue, 1));
                        $objWriter->writeElement('v', substr($cellValue, 1));
                    } else {
                        $objWriter->writeElement('v', $cellValue);
                    }

                    break;
            }
        }

        $objWriter->endElement();
    }
Write Cell.

@param XMLWriter $objWriter XML Writer
@param PhpspreadsheetWorksheet $pSheet Worksheet
@param Cell $pCellAddress Cell Address
@param string[] $pFlippedStringTable String table (flipped), for faster index searching

@throws WriterException