-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMS Excel program .py
More file actions
53 lines (48 loc) · 1.46 KB
/
MS Excel program .py
File metadata and controls
53 lines (48 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import openpyxl as xl
import openpyxl.utils as xlu
import openpyxl.styles as xls
import pywhatkit as wt
wl = xl.load_workbook("C:/Users/Admin/Desktop/Payments.xlsx")
ws = wl.active
# print(ws['B2'].value)
# ws['B2'] = "Test"
# print(ws['B2'].value)
# wl.save('C:/Users/Admin/Desktop/Payments.xlsx')
# wl.create_sheet("test")
# wl.save('C:/Users/Admin/Desktop/Payments.xlsx')
# print(wl.sheetnames)
# wk1 = xl.Workbook()
# ws1 = wk1.active
# wk1.title = 'workbook1'
# wk1.save('C:/Users/Admin/Desktop/workbook1.xlsx')
# ws1.append(["Jan","Feb","March"])
# wk1.save('C:/Users/Admin/Desktop/workbook1.xlsx')
# for row in range(2, 5):
# for col in range(1, 5):
# char = xlu.get_column_letter(col)
# print(ws[char + str(row)].value)
wb = xl.load_workbook('C:/Users/Admin/Desktop/workbook1.xlsx')
ws2 = wb.active
# ws2.merge_cells('A2:D2')
# ws2.unmerge_cells('A2:D2')
# ws2.insert_rows(3)
# ws2.insert_cols(2)
# ws2.delete_cols(2)
# ws2.delete_rows(3)
# ws2.move_range('A2:B7', rows=3, cols=2)
x = '000000'
# Fill_pattern = xls.PatternFill(fill_type='solid', fgColor=x)
# ws2['B4'].fill=Fill_pattern
# color_hex=ws2['J8'].fill.start_color.index
# print(color_hex)
mon_row = str(input('Enter the row of month'))
for row in range(1, 13):
y = mon_row + str(row)
color_hex = ws2[y].fill.start_color.index
a=str(color_hex)
print(a)
if a == '00000000':
ws2[y] = 'message'
else:
ws2[y] = 'ho'
wb.save('C:/Users/Admin/Desktop/workbook1.xlsx')