Borders not saving

59 views
Skip to first unread message

Jordan Verhofstadt

unread,
Feb 21, 2023, 2:58:09 AM2/21/23
to openpyxl-users

Hi, I'm trying to use OpenPyxl in a script I'm developing, it should open a template workbook from a folder, add a few information and saving everything into another folder with a new given name. My issue is every borders from the template disappear in the new file.

I've tried a few things but without result, borders are always missing at the end:

  • opening an empty Excel file with only some borders in it, then I just use load_workbook and I save it with another name
  • creating the workbook and adding borders directly with openpyxl in python
Versions : 
MSO 16.0.13801.20240 32bit.
python 3.10 / openpyxl==3.2.0b1  

Would someone have an idea ? Thanks

Charlie Clark

unread,
Feb 21, 2023, 5:58:14 AM2/21/23
to openpyxl-users
On 21 Feb 2023, at 8:58, Jordan Verhofstadt wrote:

> Hi, I'm trying to use OpenPyxl in a script I'm developing, it should open a
>
> template workbook from a folder, add a few information and saving
>
> everything into another folder with a new given name. My issue is every
>
> borders from the template disappear in the new file.
>
> I've tried a few things but without result, borders are always missing at
>
> the end:
>
> - opening an empty Excel file with only some borders in it, then I just
>
> use load_workbook and I save it with another name
>
> - creating the workbook and adding borders directly with openpyxl in
>
> python
>
> Versions :
>
> MSO 16.0.13801.20240 32bit.
>
> python 3.10 / openpyxl==3.2.0b1

You're using an unsupported beta version!

As with so many things, it's impossible to say much without a file.

Charlie

--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Sengelsweg 34
Düsseldorf
D- 40489
Tel: +49-203-3925-0390
Mobile: +49-178-782-6226

Jordan Verhofstadt

unread,
Feb 21, 2023, 9:27:18 AM2/21/23
to openpyxl-users
Same thing with newest stable version, 3.1.1

As said, it happens with any file. Even one I create and just add some borders.

See attached, a simple file "Before.xlsx" copied with openpyxl into "After.xlsx"

And a simple code :

import openpyxl

wb = openpyxl.load_workbook(r'C:\Users\jrh\Desktop\Before.xlsx')
wb.save(r'C:\Users\jrh\Desktop\After.xlsx')
wb.close()


After.xlsx
Before.xlsx

Jordan Verhofstadt

unread,
Feb 21, 2023, 10:25:17 AM2/21/23
to openpyxl-users
Just resolved the issue.
This comes from the MS office version, my company has to update it

Thanks for the help.
Reply all
Reply to author
Forward
0 new messages