标签:int code excel top name get cell drm 清单
import openpyxl
workbook = openpyxl.load_workbook(r"C:\Users\PC\Desktop\EDRMHelper2\TRDP显示故障清单设置_生成.xlsx") #打开工作间
worksheet = workbook.get_sheet_by_name(‘Sheet1‘) #打开该表格
for i in range(2,2774):
fault_code = int(worksheet.cell(i,1).value)
if fault_code < 10:
print(worksheet.cell(i, 1).value + " < 10",‘\n‘)
worksheet.cell(i,1,‘000‘ + str(fault_code))
elif fault_code < 100:
print(worksheet.cell(i, 1).value + " < 100", ‘\n‘)
worksheet.cell(i, 1, ‘00‘ + str(fault_code))
elif fault_code < 1000:
print(worksheet.cell(i, 1).value + " < 1000", ‘\n‘)
worksheet.cell(i, 1, ‘0‘ + str(fault_code))
workbook.save(r"C:\Users\PC\Desktop\EDRMHelper2\TRDP显示故障清单设置_生成.xlsx") #save 才有效
标签:int code excel top name get cell drm 清单
原文地址:https://blog.51cto.com/12884584/2415474