关于excel:如何快速解除Excel表格工作表保护

1. 解除Excel表格工作表爱护的办法

如下文档介绍了Excel表格解除工作表爱护的办法,根本的套路就是把excel表格改名一个压缩包文件,接着从压缩包文件中取出对应的sheet页面的配置xml文件,而后把该xml文件中的sheetProtection节点删除掉。最初把文件放入压缩包,并复原为原excel后缀。从新关上excel表格,该sheet页面的表格爱护已被解除。
https://www.jianshu.com/p/b01…
https://www.cnblogs.com/shadr…

2. 应用python疾速解除工作表爱护

如果sheet页面比拟多,一一去批改比拟麻烦,所以这里提供一个应用python脚本疾速批改的计划:

import os
import re
import xml.dom.minidom

def delete_protection_node(xml_file):
    doc = xml.dom.minidom.parse(xml_file)
    root = doc.documentElement

    for parent in root.childNodes:
        if(parent.tagName == 'sheetProtection'):
            root.removeChild(parent)

    with open(xml_file, 'w', encoding='UTF-8') as f:
        doc.writexml(f)


walk_names = os.walk(r'xl\worksheets')
for (directory, sub_directorys, file_names) in walk_names:
    for name in file_names:
        m = re.match(r'(.+\.)xml$', name, re.I)
        if m:
            delete_protection_node(os.path.join(directory, name))

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理