Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mirror cell range in excel
#1
Hey people

I'm new with Python programming so I don't know much. I have a problem with coping a range of cells with formatting but in reverse order(to mirror it precisely). This table represents the front and back of the 2 sided sheet when you look at them. I have the left range(always the same) formatted in a way that I need. So I will change the color and numbers. I want to get the second table next to this one but mirrored. Something like this https://ibb.co/0hHSk28.

Below is my code.
import openpyxl as xl


def process_workbook(filename):
    wb = xl.load_workbook(filename)
    sheet = wb.active
    mr = sheet.max_row
    mc = sheet.max_column

    for i in range(2, mr + 1):
        for j in reversed(range(2, mc + 1)):
            cell = sheet.cell(row=i, column=j)
            sheet.cell(row=i, column=j+11).value = cell.value
    wb.save('henkel.xlsx')


filename = 'henkel.xlsx'
process_workbook(filename)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Mirror Video Image in realtime makingwithheld 1 395 Oct-30-2023, 02:45 PM
Last Post: Larz60+
  Deleting rows based on cell value in Excel azizrasul 11 2,474 Oct-19-2022, 02:38 AM
Last Post: azizrasul
  matplotlib x axis range goes over the set range Pedroski55 5 3,102 Nov-21-2021, 08:40 AM
Last Post: paul18fr
  Using Excel Cell As A Variable In A Loop knight2000 7 4,013 Aug-25-2021, 12:43 PM
Last Post: snippsat
  Using Excel Cell As A Variable In A Loop knight2000 7 4,894 Jul-18-2021, 10:52 AM
Last Post: knight2000
  Python “Formula” Package: How do I parse Excel formula with a range of cells? JaneTan 1 2,639 Jul-12-2021, 11:09 AM
Last Post: jefsummers
Smile Set 'Time' format cell when writing data to excel and not 'custom' limors 3 6,195 Mar-29-2021, 09:36 PM
Last Post: Larz60+
  How to append a value to specific excel cell using openpyxl hobbyist 0 4,762 Mar-05-2021, 07:14 PM
Last Post: hobbyist
  how to reference excel range one by one mqzhang99 1 1,621 Sep-12-2020, 04:31 AM
Last Post: buran
  data frame excel cell calulation buunaanaa 1 1,815 Jul-04-2020, 06:00 PM
Last Post: buunaanaa

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020