I have some rudimentary knowledge of openpyxl and having some issues here. I want to write some data (say "qwerty") to cell D4 of Sheet1 and "abcd" to cell "P7" of sheet 2. The workbook and the sheets do exist already. This is my code snippet:
from openpyxl import Workbook
excel = openpyxl.load_workbook('pqr.xlsx',read_only=False)
Sheet1 = excel.active
Sheet1['D4'] = 'qwerty'
#excel.save('pqr.xlsx')
Sheet2 = excel.active
Sheet2['P7'] = 'abcd'
excel.save('pqr.xlsx')
However, it ends up writing both the data on the Sheet1 cells only. Any help would be greatly appreciated. Thanks, Swanand.