Failing to parse formatting.

Issue #565 resolved
StephenGore
created an issue

I have recently attempted to open a worksheet and an error occurred in the content property of "Cell\Text.py". The error is "TypeError: sequence item 3: expected str instance, NoneType found". After taking a look in the sharedstrings.xml I found the error happened when parsing the following XML.

<si>
  <r>
    <t>“Replaced Data”</t>
  </r>
  <r>
    <rPr>
      <sz val="11"/>
      <color rgb="FF008080"/>
      <rFont val="Calibri"/>
      <family val="2"/>
      <scheme val="minor"/>
    </rPr>
  <t/>
  </r>
</si>

I think it is to do with the "<t/>" tag and not finding any data. More information at http://stackoverflow.com/questions/34094049/failing-to-open-spreadsheet/

Comments (7)

  1. CharlieC

    Thanks. If this is really extracted from an existing file then it's pretty odd because the styled text is empty. Almost worth raising an exception for!

    Is this an original Excel file? If not I suggest submitting a report on whichever library created the file.

  2. David Wheeler

    Related to this - does openpyxl (presently) support changes in text styling within a cell? The example below is from MS Excel sharedStrings.xml where the word bold is in (well) bold. This is equivalent to a paragraph.run in python-docx.

        <si>
            <r>
                <t xml:space="preserve">text with </t>
            </r>
            <r>
                <rPr>
                    <b/>
                    <sz val="12"/>
                    <color theme="1"/>
                    <rFont val="Calibri"/>
                    <family val="2"/>
                    <scheme val="minor"/>
                </rPr>
                <t>bold</t>
            </r>
            <r>
                <rPr>
                    <sz val="12"/>
                    <color theme="1"/>
                    <rFont val="Calibri"/>
                    <family val="2"/>
                    <scheme val="minor"/>
                </rPr>
                <t xml:space="preserve"> emphasis</t>
            </r>
        </si>
    

    Apologies if it's in here and I didn't find it.

  3. Log in to comment