excel帶格式復制python


openpyxl 復制cell單元格包括所有樣式

target_cell.data_type = source_cell.data_type
target_cell.fill = copy(source_cell.fill)
if source_cell.has_style:
    target_cell._style = copy(source_cell._style)
    target_cell.font = copy(source_cell.font)
    target_cell.border = copy(source_cell.border)
    target_cell.fill = copy(source_cell.fill)
    target_cell.number_format = copy(source_cell.number_format)
    target_cell.protection = copy(source_cell.protection)
    target_cell.alignment = copy(source_cell.alignment)
 
if source_cell.hyperlink:
    target_cell._hyperlink = copy(source_cell.hyperlink)
 
if source_cell.comment:
    target_cell.comment = copy(source_cell.comment)
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM