Cell copy including cell format or keeping cell format

Issue #783 closed
Stephane Lecolier
created an issue


I am updating XLSX sheets from other XLSX sheet, but I have remark that:

  • either it is not possible to keep format of targeted cell

  • either it is not possible to keep format from original cell

Is it a limitation of OpenPyXL library or do you have a recommendation in order to do that? Because of that, as original cell format is lost, process can be achieved properly and it is blocking us.

I don't have find any guidelines about this point. I'm using OpenpyXL 2.4.1,

Best Regards,


Comments (8)

  1. CharlieC

    Questions should be addressed to the mailing list.

    Otherwise please supply a sample file with relevant code and an explanation of what is wrong, thanks.

  2. Stephane Lecolier reporter

    Let me explain briefly with a short code example:


    import sys,openpyxl,re import warnings warnings.filterwarnings("ignore")

    Start Acronyms Checks

    from openpyxl.cell import get_column_letter from openpyxl.styles import Font, PatternFill , Color, colors, Border from html import unescape

    inp='tm.xlsx' wb = openpyxl.load_workbook(inp)

    sheet = wb.get_sheet_by_name('Sheet1')

    v = sheet['A3'].value print ('\nA3 value: %s\n' % v) sheet['A3']='ORANGE' # substitute value by another value belonging to rolling list

    v = sheet['A3'].value # now: rolling list is broken but nothing prevents to use value print ('A3 new value: %s\n' % v)

    v = sheet['A4'].value print ('A4 value: %s\n' % str(v)) sheet['A4']='BLACK' # substitute value by another value NOT belonging to rolling list

    sheet['B5'] = str(sheet['A5'].value) # Test cell copy : Rolling not exported within B5 cells v = sheet['B5'].value print ('B5 value: %s\n' % str(v))


  3. CharlieC

    Please format your code so that it's readable but basically I don't see a problem.

    openpyxl is a file format library and as such allows you to define things like data validations but it doesn't enforce them. B5 is not covered by the data validation rules for the worksheet.

  4. Log in to comment