简体   繁体   English

如何使用Python正确复制“ .xlsx”文件

[英]How to copy correctly “.xlsx” file with Python

I am working with Excel and Python. 我正在使用Excel和Python。 I want to copy and modify an Excel file with ".xlsx" extension, using a script written in Python. 我想使用Python编写的脚本复制和修改扩展名为“ .xlsx”的Excel文件。 The file contains a specific format and some cells have a specific styles. 该文件包含特定格式,某些单元格具有特定样式。 When I am working with ".xls" extension file, I am using "formatting_info" for copying the Excel file in a workbook like this: 当我使用“ .xls”扩展文件时,我正在使用“ formatting_info”在工作簿中复制Excel文件,如下所示:

readBook = open_workbook(fileName, formatting_info=True)

and then modified it and then save it. 然后修改它,然后保存它。

The problem is that I can't use "formatting_info" with ".xlsx" file; 问题是我不能将“ formatting_info”与“ .xlsx”文件一起使用;

I got an error: 我收到一个错误:

formatting_info=True not yet implemented

I was looking for a solution; 我一直在寻找解决方案; but I didn't find anything which helped me. 但是我没有找到任何对我有帮助的东西。

The question is: is there a way to copy and modify that ".xlsx" file and keep the style and the font? 问题是:有没有办法复制和修改该“ .xlsx”文件并保留样式和字体?

I attach an example: 我举一个例子:

在此处输入图片说明

The same is the case, there is at the following link: 情况相同,以下链接中有:

python xlutils : formatting_info=True not yet implemented python xlutils:formatting_info =尚未实现

formatting_info=True 

only works on .xls not .xlsx file. 仅适用于.xls而不适用于.xlsx文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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