Fixed handling of inline strings in XLSX (#2569)
* Fixed handling of inline strings * Added an example for the "inline string" datatype for which the generated XML was fixed in the previous commit. * Handle inline strings exactly the same way as regular strings in the XLS writer, because this is only relevant in the XLSX format.
This commit is contained in:
parent
5bf0656e92
commit
90e9ea9505
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
|
@ -144,6 +145,11 @@ $spreadsheet->getActiveSheet()
|
|||
$spreadsheet->getActiveSheet()
|
||||
->setCellValue('C18', '=HYPERLINK("mailto:abc@def.com","abc@def.com")');
|
||||
|
||||
$spreadsheet->getActiveSheet()
|
||||
->setCellValue('A20', 'String')
|
||||
->setCellValue('B20', 'inline')
|
||||
->setCellValueExplicit('C20', 'This will not be added to sharedStrings.xml', DataType::TYPE_INLINE);
|
||||
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getColumnDimension('B')
|
||||
->setAutoSize(true);
|
||||
|
|
|
|||
|
|
@ -433,6 +433,7 @@ class Worksheet extends BIFFwriter
|
|||
} else {
|
||||
switch ($cell->getDatatype()) {
|
||||
case DataType::TYPE_STRING:
|
||||
case DataType::TYPE_INLINE:
|
||||
case DataType::TYPE_NULL:
|
||||
if ($cVal === '' || $cVal === null) {
|
||||
$this->writeBlank($row, $column, $xfIndex);
|
||||
|
|
|
|||
|
|
@ -1189,10 +1189,12 @@ class Worksheet extends WriterPart
|
|||
{
|
||||
$objWriter->writeAttribute('t', $mappedType);
|
||||
if (!$cellValue instanceof RichText) {
|
||||
$objWriter->startElement('is');
|
||||
$objWriter->writeElement(
|
||||
't',
|
||||
StringHelper::controlCharacterPHP2OOXML(htmlspecialchars($cellValue, Settings::htmlEntityFlags()))
|
||||
);
|
||||
$objWriter->endElement();
|
||||
} elseif ($cellValue instanceof RichText) {
|
||||
$objWriter->startElement('is');
|
||||
$this->getParentWriter()->getWriterPartstringtable()->writeRichText($objWriter, $cellValue);
|
||||
|
|
|
|||
Loading…
Reference in New Issue