How can python copy excel cells value together with its color and equation,etc(如何将EXCEL单元格的值与其颜色、公式等一起复制)
问题描述
找了又试,到目前为止还没有找到解决方案...
1.使用Openpyxl
例如:ws_to.cell(row1, column1).value = ws_from.cell(row2,column2).value
2.使用win32com.client
例如:
xlsSheet.Cells(row1, column1).Value = xlsSheet.Cells(row2, coloum2).Value
上面的两个模块都无法复制单元格,保持其颜色和方程式。
是否有更强大的模块来帮助我在复制单元格时保留颜色和方程式?
推荐答案
使用win32com.client
可以使用Range.Copy(destination)
:
xlsSheet.Cells(row2, column2).Copy(xlsSheet.Cells(row1, column1))
这将复制所有内容,就像您执行ctrl-c ctrl-v(值、格式设置等)一样。
这篇关于如何将EXCEL单元格的值与其颜色、公式等一起复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!