Conditional formatting lost

Issue #493 resolved
vgrass created an issue


i've an issue with openpyxl 2.2.5. Conditinal formatting is lost just after loading a workbook and saving it without even changing any data. I've attached sample files. The file is even 3kb smaller afterwards.

from openpyxl import load_workbook

sFileName = 'test.xlsx'

ws = load_workbook(filename = sFileName) = sFileName)

Comments (9)

  1. CharlieC

    The problem is that the original file uses extensions to conditional formatting that are not covered in the specification. In this case all the conditional formatting is embedded as an extension.

    Which version of Office are you using? You might want to check the compatibility settings.

  2. vgrass reporter

    I'm using Office Professional Plus 2010 Excel Version 14.0.7151.5001 (32-Bit)

    I've just discovered that images are also lost.

  3. CharlieC

    Images have always been lost when processing files. That will hopefully change in a future version.

    I think the formatting can be retained if the rule is expressed differently.

  4. CharlieC

    Yes, it's specified as an extension. If only it were as easy as supporting an additional tag. However, Excel does this by creating the extension and the format in one place at linking to it from another. This is tricky to manage, though we'll hopefully get round to it one day. If you look at the code it uses, almost anything would be preferable to it.

    Compare: classic formatting:

      <cfRule type="expression" priority="1" dxfId="1">

    Excel 2010+

        <x14:cfRule type="containsText" priority="2" operator="containsText" id="{77F12508-0BE0-4B3F-9C57-4DEEF91E7B07}">
            <color rgb="FF0000FF"/>
             <bgColor rgb="FF99CCFF"/>
  5. Log in to comment