1

I am working with Excel and Python. I want to copy and modify an Excel file with ".xlsx" extension, using a script written in Python. 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:

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;

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?

I attach an example:

enter image description here

Romulus
  • 1,150
  • 3
  • 16
  • 26
  • Yes, I have already tried using openpyxl. – Romulus Mar 15 '14 at 18:58
  • There is another library called [XlsxWriter](https://xlsxwriter.readthedocs.org/), have you tried that one? – filmor Mar 15 '14 at 19:31
  • No. I will try it. It looks promising. Thank you very much! – Romulus Mar 15 '14 at 21:36
  • I tried XlsxWriter, but unfortunately it has a big disadvantaged: "It cannot read or modify existing Excel XLSX files." :( – Romulus Mar 16 '14 at 09:58
  • 1
    @RemusAvram only openpyxl supports both *reading* and *writing* files. Please file any issues on the bug tracker and use the mailing list for general questions. – Charlie Clark Mar 18 '14 at 17:05
  • @bernie: Your information is out of date. `xlrd` *does* read `.xlsx` files. What it doesn't do is read the *formatting* in `.xlsx` files. (It *does* read the formatting in `.xls` files, however, which is why OP framed his question the way he did.) – John Y Mar 19 '14 at 20:49
  • @user2385133 thank you for your advise. I will try to do that. I think they have already answered at this question for many times. – Romulus Mar 20 '14 at 08:47
  • Thanks, @JohnY. I deleted my other comment. – mechanical_meat Mar 20 '14 at 20:39

1 Answers1

2

The same is the case, there is at the following link:

python xlutils : formatting_info=True not yet implemented

formatting_info=True 

only works on .xls not .xlsx file.

Community
  • 1
  • 1
kamzur
  • 19
  • 1
  • 3