wangliyao
发表于 2021-9-30 16:59:29
111
xingkong0214
发表于 2021-10-13 14:48:51
# coding:utf-8
import openpyxl
wb = openpyxl.load_workbook(r'豆瓣TOP250电影.xlsx')
ws = wb['Sheet Copy']
for each_row in ws.iter_rows(min_row=2, min_col=1, max_row=ws.max_row, max_col=2):
if each_row.value == "阿甘正传":
each_row.value = 9.8
elif each_row.value == "这个杀手不太冷":
each_row.value = 9.6
elif each_row.value == "肖申克的救赎":
each_row.value = 9.4
wb.save('豆瓣TOP250电影.xlsx')
lychee007007
发表于 2021-10-19 14:40:51
111
pipifish
发表于 2021-10-28 15:29:38
朕想知道
背包儿郎
发表于 2021-10-31 19:07:04
nice
背包儿郎
发表于 2021-10-31 19:08:46
suishoufang 发表于 2018-4-25 11:47
执行:wb.get_sheet_names()和 ws = wb.get_sheet_by_name('Sheet')时候,
报错提示:
File "__main__",...
官方提示建议我们用 wb函数代替get_sheet_by_name
背包儿郎
发表于 2021-10-31 19:23:06
for each_row in ws.rows:
if each_row.value in data_updates:
each_row.value = data_updates.value]
这段代码有点糊涂,那位大神帮解答下{:10_266:}
鸡肉味嘎嘣脆
发表于 2021-11-7 08:58:48
朕想知道
eeyling
发表于 2021-11-8 18:08:32
查看参考代码!
lxq2013
发表于 2021-11-18 20:33:27
openpyxl.cell.cell.column_index_from_string('JB')调用时提示“AttributeError: module 'openpyxl.cell.cell' has no attribute 'column_index_from_string'”,已经取消了?
FPastime
发表于 2021-11-21 12:34:01
学习学习
mu61
发表于 2021-12-5 14:24:50
import openpyxl as xl
wb = xl.load_workbook("豆瓣TOP250电影.xlsx")
ws = wb]
modifyDict ={"阿甘正传" : 9.8, "这个杀手不太冷" : 9.6, "肖申克的救赎" : 9.7}
for i in range(2, 252):
for each in modifyDict:
if each in ws["A{}".format(i)].value:
ws["B{}".format(i)] = modifyDict
wb.save("豆瓣TOP250电影.xlsx")
youshulx
发表于 2021-12-5 18:05:29
for i in wb1.rows:
for j in wb2.rows:
if i == j:
i = j
break
54san
发表于 2021-12-8 12:24:54
+1
甜蜜难在
发表于 2021-12-10 17:42:11
from openpyxl import load_workbook
import openpyxl
from openpyxl.utils import get_column_letter,column_index_from_string
wb = load_workbook(filename=r"d:\Users\zhongsong\Desktop\豆瓣TOP250电影.xlsx")
ws = wb.active
titles = wb.sheetnames
a = '阿甘正传'
b = '这个杀手不太冷'
c = '肖申克的救赎'
d = []
for i in ws:
for j in i:
if j.value == a:
j.offset(0,1).value = 9.8
print(j.value,j.offset(0,1).value)
elif j.value == b:
j.offset(0,1).value = 9.6
print(j.value,j.offset(0,1).value)
elif j.value == c:
j.offset(0, 1).value = 9.7
print(j.value,j.offset(0, 1).value)
liyi1376202
发表于 2021-12-25 13:20:17
0
MildHeart
发表于 2022-1-4 10:31:12
朕想知道
草莓-su
发表于 2022-1-7 21:32:58
1
ygrong_2008
发表于 2022-1-14 15:08:19
学习一下
是阿佳!
发表于 2022-1-18 16:05:41
import openpyxl as xl
wb = xl.load_workbook(r'test.xlsx')
ws = wb.active
ws['B4'] = 9.8
ws['B6'] = 9.7
ws['B2'] = 9.6
wb.save(r'test.xlsx')