python有很多包可以操作excel单元
其中我用过的有xlrd ,xlwt 一个读一个写, 另外可用 openpyxl或者XlsxWriter 进行读写, 非常简单
读写单元格只需按列表一样读写元素即可
ws['A1'] = 42
a = ws["A2"]
对应的python模块用法可以参考网上教程!
try:
getattr(ws.cell(row=m, column=c), "value")
cell1 = ws[i] # 获取data单元格数据
ws2[i].value = cell1.value # 赋值到ws2单元格 这里不是追加,而是相同位置复制
if cell1.has_style: # 拷贝格式
ws2[i].font = copy(cell1.font)
ws2[i].border = copy(cell1.border)
ws2[i].fill = copy(cell1.fill)
ws2[i].number_format = copy(cell1.number_format)
ws2[i].protection = copy(cell1.protection)
ws2[i].alignment = copy(cell1.alignment)
except AttributeError as e:
print("cell(%s) is %s" % (i, e))