简体   繁体   中英

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. I need to copy this sheet to another workbook(excel sheet) without loosing the formatting(colour combination, wrap texting, cell size etc.) using python

Copying just the data is easy enough> Formatting & styles are part of the workbook, to maintain these need to be copied as well. 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. How to copy over an Excel sheet to another workbook in Python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM