npm package: @iimm/word-excel-unprotect
Description: remove editting restrictions of the word or excel file. 移除Word/Excel文件的限制编辑
Latest version: 0.0.1

# @iimm/word-excel-unprotect

[![NPM version](https://img.shields.io/npm/v/@iimm/word-excel-unprotect.svg?style=flat)](https://npmjs.com/package/@iimm/word-excel-unprotect)
[![NPM downloads](http://img.shields.io/npm/dm/@iimm/word-excel-unprotect.svg?style=flat)](https://npmjs.com/package/@iimm/word-excel-unprotect)

## Description
一个简单的React组件，在纯浏览器环境中解除Word或Excel文件的编辑限制(如果设置了打开文件就需要输入密码则不可以)

a simple React component to unprotect Word or Excel files in pure browser environment. while if the password is required when a file is opened, it cannot be unprotected.

## Preview
![预览图][figure]

[figure]:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR0AAABMCAYAAABQz2OdAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABoISURBVHhe7Z17XBTnuce/UckqVZGEIKAHiBfQKMRoDGuiNtV6jabngNHWg2l2461KOGytxISYmiq5aDzrBW1Eg02w9oguicU7aiJaXfRoFOMFlQQ4CohUXKOYzap7/phZdnbYRUUFrO/385nPznudy+785nme992ZR+x2ux2BQCCoJ5qoMwQCgeB+IkRHIBDUK0J0BAJBvSJERyAQ1CtCdAQCQb0iREcgENQrQnQEAkG9IkRHIBDUK0J0BAJBvfKIpxnJZWVlZGZmUlRUpC566AgJCSE6OpqAgAB1kUAguEM8is7SpUvp0qULPXv2VBc9dBw6dIiTJ08yZcoUdZFAILhDPLpXRUVFQnBkevbsKSw+geAe4VF0BAKB4H4gREcgENQrQnQEAkG98uCKztVy8nafwqLObyisFixWdaYCWxVVNnWmG2xVWCy3U1FQn9jKT5BXWKXOFtSBuxIdy9E8yq8rMq6eImd7HpbrOczsFk78Fg9X4dF04hPSyVPn3wmnUnn15SgmmDxsQ0GRaSZzTEU4a+aRnhBP+lGXandFQcYsDB9tdYqgrYrSkwfZaVrJvJlxTPqdgaSUnVS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ntpzSFzzzSl1wJ3giVxr4fMdcNhRlt4byXkdQDdcxDzGBSfhv5ybGr+qxBjrTmsHVwMUZuk9MDOcLolZPUBn6aABd7+XBq16ttBsqCKfwGFncDoEK4OkPsSUAZ7zsGmAsnC6f40LI0Cy3EYuce5TeWcnOp5Oo6/XbSWhvRPn3TutxoxZC5oKOouOo2Aey06t8PY5+EFYOpedcmDhRAdQUPh0b1q6vUIyE/qa4xcq/oJgGaPOv5IemvuoKpHVu998AWHm5Ivpmnm8esXCO4bHn91bTtL47j5OVfURY2Cf2w6BkCnbtITBG+HnuKtwADcuCj5Y706ev4Hv0Bwv/AoOt0HSf9j2LehkO3rvqm2LBqaa1U/sX3dN/zlo+0ADIjuoa7ikXER8srVCm5UFFTf8R8abtq4UVGA7aw0/q57sYO6hkBw3/EY0wHITivgsz9nqrMbDU8+FcDsz8aps2slOfsiH6/eqc5+6HjmSV92vuuY5ywQ1B+1ig7A3i0n2Jl5mDPHSu/o0aD3i2aPNqVTt0AGRPe47bdAqFlnLmbl199xsODiQ/XITk2zJvTq+Bi6FzuIt0AIGoxbio5AIBDcSzzGdAQCgeB+IERHIBDUK0J0BAJBvSJERyAQ1CtCdAQCQb0iREcgENQrQnQEAkG9IkRHIBDUK0J0BAJBvSJERyAQ1Cv/D1t3+yMMBYAXAAAAAElFTkSuQmCC

## Install

```bash
# pnpm
$ pnpm add @iimm/word-excel-unprotect

# npm
$ npm i @iimm/word-excel-unprotect

# yarn
$ yarn add @iimm/word-excel-unprotect
```



## Props

```typescript
export let wordOrExcelUnprotectTranslations = {
  reset: {
    zh: "重置",
    en: "Reset",
  },
  unprotect: {
    zh: "解除限制",
    en: "Unprotect",
  },
  extentionCheckMsg: {
    zh: `不是支持的docx或xlsx文件格式,请另存为(直接修改扩展名无效)支持的格式：`,
    en: `Not a supported docx or xlsx file format, please save as (modifying the extension name directly is invalid) supported formats: `,
  },
  magicNumberCheckMsg: {
    zh: "文件魔数检查：不是有效的docx或xlsx文件",
    en: "File magic number check: not a valid docx or xlsx file",
  },
  xmlCheckMsg: {
    zh: "文件结构检查：不是有效的docx或xlsx文件",
    en: "File structure check: not a valid docx or xlsx file",
  },
  unknownErrorMsg: {
    zh: "未知错误",
    en: "Unknown error",
  },
  noEdittingRestrictionMsg: {
    zh: "原文件没有限制编辑",
    en: "The original file does not have any editing restrictions",
  },
};

interface WordOrExcelUnprotectProps {
    className?: string;
  /**
   * @default 'zh'
   */
  lang?: ("zh" | "en") & {};
  translations?: Record<keyof typeof wordOrExcelUnprotectTranslations, Record<string, string>>;
  /**
   * @default 'iimm-'
   */
  fileNamePrefix?: string;
}
```

## Styles 

```css
.iimm-unprotect-container {
  width: 100%;
  padding: 5px;
}

.iimm-unprotect-input {
  padding: 5px;
}

.iimm-unprotect-error {
  color: red;
  font-weight: bold;
  margin-top: 5px;
  margin-bottom: 5px;
}

.iimm-unprotect-reset {
  margin-left: 5px;
  margin-right: 5px;
  background: transparent;
  border-color: #9254de;
  border-radius: 5px;
  min-width: 15px;
  min-height: 10px;
  color: #722ed1;
  cursor: pointer;
}

.iimm-unprotect-action {
  margin-left: 5px;
  margin-right: 5px;
  background: #1890ff;
  border-color: #1890ff;
  border-radius: 5px;
  min-width: 25px;
  min-height: 10px;
  color: white;
  cursor: pointer;
}

```

## LICENSE

MIT