Skip to content

XML-Reader: support rich text #4001

@SlowFox71

Description

@SlowFox71

This is:

- [ x] a feature request

What is the expected behavior?

Accept formatting instructions, if present

What is the current behavior?

Everything is parsed as text

What are the steps to reproduce?

Read the attached file with XML reader and save as XLSX.

What features do you think are causing the issue

  • [x ] Reader

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

XML reader only

I implemented the desired behaviour in Xml::loadIntoExisting() in a rather brute-force way like follows (untested); there might be a much better way to extract the inner content of the SimpleXMLElement:

    case 'String':
        $type = DataType::TYPE_STRING;
        
        $rich = $cellData->children('http://www.w3.org/TR/REC-html40');
        if ($rich) {
            # in case of HTML content we extract the payload
            # and convert it into a rich text object
            $content = $cellData->asXML(); 
            $start = strpos($content, '<', 1);
            $end = strrpos($content, '<');
            $content = substr($content, $start, $end-$start);
                                           
            $html = new Helper\Html();
            $cellValue = $html->toRichTextObject($content);
         }
    
                                break;

richtext_xml.txt

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