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
Smile Set 'Time' format cell when writing data to excel and not 'custom' limors 3 483 Mar-29-2021, 09:36 PM
Last Post: Larz60+
  How to append a value to specific excel cell using openpyxl hobbyist 0 592 Mar-05-2021, 07:14 PM
Last Post: hobbyist
  how to reference excel range one by one mqzhang99 1 430 Sep-12-2020, 04:31 AM
Last Post: buran
  data frame excel cell calulation buunaanaa 1 725 Jul-04-2020, 06:00 PM
Last Post: buunaanaa
  Loop Excel Range Kristenl2784 2 857 Jun-18-2020, 04:49 PM
Last Post: Kristenl2784
  Define a range, return all numbers of range that are NOT in csv data KiNeMs 18 2,339 Jan-24-2020, 06:19 AM
Last Post: KiNeMs
  Python not reading cell in excel file wendysling 1 914 May-21-2019, 10:40 PM
Last Post: Larz60+
  find cell value with matching regular expression of a row in excel file hruday 4 26,211 Jul-05-2017, 01:02 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

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