我正在使用python自动化使用excel工作表列表创建多个名称标记的过程
我的问题是我需要取'name'列和'enterprise'列的值把它们放在新文档的一个单元格里
像这样:
对此:
现在我正在使用openpyxl,虽然我设法转移了其中一个列,但不能同时使用这两个列。 下面的代码是我尝试过的东西之一
import openpyxl as xl
e = xl.load_workbook('etiquetas.xlsx')
eplan = e['Planilha1']
c = xl.load_workbook('Crachá Relação 15.10.19.xlsx')
cplan = c['Plan1']
maxlinhas = cplan.max_row
for i in range (2, maxlinhas+1):
nome = cplan.cell(row = i, column = 1).value
preenchernome = eplan.cell(row = i-1, column = 1)
empresa = cplan.cell(row=i, column=2).value
preencherempresa = eplan.cell(row=i - 1, column=1)
preenchernome.value = nome, empresa
e.save('teste.xlsx')
但此代码返回以下错误:
ValueError: Cannot convert ('Gladisson Garcia Westphal', 'Agro Divel') to Excel
根据文档
preenchernome.value
只能有一个值试着用这个
传递给目标单元格的值应该是单个字符串。因此:
应该没问题。这就是我的全部代码:
相关问题 更多 >
编程相关推荐