[英]How to copy contents from a sheet of an excel workbook to another workbook without loosing the excel formatting using python
I have an excel sheet with specific formatting done.我有一张 excel 表格,并完成了特定的格式化。 I need to copy this sheet to another workbook(excel sheet) without loosing the formatting(colour combination, wrap texting, cell size etc.) using python我需要使用 python 将此表复制到另一个工作簿(excel 表)而不丢失格式(颜色组合、换行、单元格大小等)
Copying just the data is easy enough> Formatting & styles are part of the workbook, to maintain these need to be copied as well.仅复制数据很容易> 格式化和 styles 是工作簿的一部分,为了维护这些也需要复制。 You don't say if the 'another workbook' is existing or you want to copy the sheet to a newly created workbook.您没有说“另一个工作簿”是否存在,或者您想将工作表复制到新创建的工作簿中。 If the later then making copies of the workbook with a new name is probably easier even if it contains extra sheets you need to delete.如果后者使用新名称复制工作簿可能会更容易,即使它包含您需要删除的额外工作表。 If the later look at the discussion in the following link has options in Solution 2 and 3 which use pywin32 and xlwings respectively.如果稍后查看以下链接中的讨论,解决方案 2 和 3 中的选项分别使用 pywin32 和 xlwings。 How to copy over an Excel sheet to another workbook in Python 如何将 Excel 工作表复制到 Python 中的另一个工作簿
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.