Skip to content

RichText can not get the correct value, when one part is plain text and the other part is rich text. #442

@expbenson

Description

@expbenson

This is:

- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

When I use RichText()->getPlainText(), I should get complete text, contain plain text and rich text.

What is the current behavior?

In xlsx, Like cell value: "plain text, rich text", RichText()->getPlainText() only return the rich text part("rich text"). the first part is missing.

What are the steps to reproduce?

In source code https://github.com/PHPOffice/PhpSpreadsheet/blob/develop/src/PhpSpreadsheet/Reader/Xlsx.php, line 2070

foreach ($is->r as $run) {
    if (isset($run->rPr)) {
        // ...
    }
}

missing the else part.

It should be

if (isset($run->rPr)) {
    // ...
} else {
    $value->createText(StringHelper::controlCharacterOOXML2PHP((string) $run->t));
}

In Xlsx, a cell can contain part to plain text, and the other part of rich text.
In above, $run element can only have "t" attribute.

Which versions of PhpSpreadsheet and PHP are affected?

PhpSpreadsheet 1.2.0, PHP 7.1.6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions