-
Notifications
You must be signed in to change notification settings - Fork 0
/
Script.py
57 lines (36 loc) · 977 Bytes
/
Script.py
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
54
55
56
57
import openpyxl
wb = openpyxl.load_workbook("Table.xlsx")
print(type(wb))
print(wb.get_sheet_names())
sheet = wb.get_sheet_by_name('Sheet3')
print(sheet)
print(sheet.title)
sheet1 = wb.get_sheet_by_name('Sheet1')
print(sheet1['A2'])
print(sheet1['A2'].value)
x2 = sheet1.cell(row=1, column=2)
print(x2)
x3 = sheet1.cell(row=1, column=2).value
print(x3)
x4 = sheet1.get_highest_row()
print(x4)
x5 = sheet1.get_highest_column()
print(x5)
x6 = sheet1.columns[1]
print(x6)
for objects in x6:
print(objects.value)
# Creating a Workbook
wb = openpyxl.Workbook()
print(wb.get_sheet_names())
sheet2 = wb.get_active_sheet()
sheet2.title = 'New Title'
print(sheet2.title)
print(wb.get_sheet_names())
print(wb.create_sheet(index=0, title='First Sheet'))
print(wb.remove_sheet(wb.get_sheet_by_name('FirstSheet')))
sheet2['A1'] = 'VALUE'
print(sheet2['A1'])
sheet2.row_dimensions[1].height = 70
sheet2.column_dimensions['B'].width = 20
wb.save('example_copy.xlsx')