python3.5 openpyxl2.5可以用这个文件解决
文件名为:fix_border.py,代码见下面的代码片
在你写代码的那个文件里导入该文件
from fix_border import patch_worksheet
然后在load文件前加上patch_worksheet()
全部代码为
ws = opx.load_workbook(filename1)
fix_border.patch_worksheet()
ws.save(filename2)
fix_border.py代码为
# -*- coding:utf-8 -*-
from itertools import product
import types
import openpyxl
from openpyxl.utils import get_column_letter
from openpyxl import worksheet
from openpyxl.utils import range_boundaries
from itertools import product
import regex as re
def patch_worksheet():
"""This monkeypatches Worksheet.merge_cells to remove cell deletion bug
https://bitbucket.org/openpyxl/openpyxl/issues/365/styling-merged-cells-isnt-working
Thank you to Sergey Pikhovkin for the fix
"""
def merge_cells(self, range_string=None, start_row=None, start_co