跳到主要内容

解锁 Excel

PDF4me 解锁 Excel 是一个 REST 移除密码保护的端点 Excel 输入正确的密码后,即可打开工作簿。 POST 受保护的文件 Base64office/ApiV2Excel/ExcelUnlock将密码输入进去 unlockExcelAction并将解码后的未加密副本保存下来。 JSON 回应。它移除了保护层;但它从未破解它。

此端点的作用

该工具接受受保护的工作簿及其密码,并返回一个未受保护的副本。文件加密、工作簿结构保护和工作表锁定都会在一次操作中全部移除,这是自动化流程在读取单元格、添加行或合并文件之前所必需的:其他所有操作都需要先执行一次。 Excel 操作需要一个未受保护的工作簿。响应是: JSON 结果为 Base64 内容。

相关博客文章
目前尚无关于此功能的博客文章——敬请期待。
在此期间,您可以浏览 PDF4me 博客,查看适用于各平台的教程和工作流程。
访问博客

验证您的身份 API 要求

每一个 PDF4me REST 通话必须包含您的 API 关键在于 Authorization 请求头设置为基本身份验证。请从开发者控制面板获取或轮换您的密钥。

端点

POSToffice/ApiV2Excel/Excel解锁

您不容错过的重要事实

需要正确的密码。不是破解程序。
API 当您提供用于启用该保护的密码时,即可移除该保护。它无法绕过、恢复或暴力破解未知密码;输入错误密码将返回错误信息。 success: 错误的
切勿将密码硬编码到有效载荷中。
请求体最终会出现在脚本、日志和版本控制系统中。注入 解锁Excel操作.密码 从环境变量或密钥管理器获取凭据,规则与任何凭据相同。
先解锁,然后自动执行
其他 Excel 操作(添加行、提取工作表、合并文件)需要一个未受保护的工作簿。请将 ExcelUnlock 作为第一步,并将其输出传递给后续操作。

HTTP 设置

方法: POST
URL https://api.pdf4me.com/office/ApiV2Excel/ExcelUnlock
内容类型: application/json
Authorization 基本 <您的 PDF4me API 键>

回答是 JSON检查 success 然后,举旗。 Base64-解码返回的工作簿内容并将其保存 .xlsx 扩大。

解锁会移除哪些保护措施?

Excel 安全防护采用多层设计,各层防护机制不同。使用正确的密码解锁,即可一次性移除所有防护层。

保护与行为它阻挡了什么已被移除 API
文件加密不输入密码就无法打开文件是的,使用正确的密码
工作簿结构保护添加、删除或重新排序表格是的
工作表保护编辑锁定工作表上的单元格是的
未知的、丢失的密码以上所有内容不,必须输入正确的密码。

API 身体场

范围必需的类型它的作用例子
documentRequiredobjectDocument reference carrying Name, the protected Excel filename with its extension.{ "Name": "data.xlsx" }
docContentRequiredstringBase64-encoded bytes of the password-protected workbook.UEsDBBQABgAIAAAA...
unlockExcelActionRequiredobjectAction configuration object holding the password and optional culture settings.{ "password": "..." }
passwordRequiredstringInside the action object. The password that was used to protect the file. Inject from a secret store; never hardcode.{{EXCEL_PASSWORD}}
cultureNameOptionalstringInside the action object. Culture code applied during processing.en-US

示例有效载荷

使用注入了秘密信息的密码解锁

{
"document": { "Name": "data.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"unlockExcelAction": {
"password": "{{EXCEL_PASSWORD}}"
}
}

以明确的文化解锁

{
"document": { "Name": "quarterly-report.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"unlockExcelAction": {
"password": "{{EXCEL_PASSWORD}}",
"cultureName": "en-US"
}
}

邮递员收款小贴士

Headers
Content-Type: application/json + Authorization: Basic <apiKey>.
Body
raw JSON. The password goes INSIDE unlockExcelAction, not at the root. Use a Postman environment variable for it.
Response
JSON with a success flag and Base64 workbook content. Decode the content before saving as .xlsx.
Failures
A wrong password returns success false with an errorMessage; nothing is partially unlocked and the source is untouched.

curl 示例

curl -X POST https://api.pdf4me.com/office/ApiV2Excel/ExcelUnlock \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"document": { "Name": "data.xlsx" },
"docContent": "'"$(base64 -w 0 data.xlsx)"'",
"unlockExcelAction": {
"password": "'"$EXCEL_PASSWORD"'"
}
}' \
--output response.json

什么 API 返回?

A JSON 结果将未受保护的工作簿作为 Base64

场地类型它包含什么
documentString (Base64)The unprotected workbook content. Decode to bytes and save with an .xlsx extension.
fileNameStringOutput filename for the unlocked workbook.
successBooleantrue when unlocking succeeded. Check this before decoding content.
errorMessageStringPopulated when success is false, including the wrong-password case.

代码示例

Excel 办公终端尚未包含在按百分比计费的范围内。language 示例文件夹;示例存储库包含每个请求使用的请求模式。 PDF4me 端点系列:

常问问题

Can this API unlock an Excel file without the password?+
No. The unlock action removes protection using the correct password you supply in unlockExcelAction.password. It is a workflow tool for files whose password you legitimately hold, not a password cracker or recovery service.
Which kinds of Excel protection does it remove?+
File encryption (the password prompt when opening), workbook structure protection, and worksheet protection are removed in one pass, returning a fully unprotected copy of the workbook.
Is the response the file itself?+
No. The API returns JSON containing the unlocked workbook as a Base64 string plus fileName, success, and errorMessage fields. Decode the content to bytes before saving as .xlsx.
What happens if I send the wrong password?+
The operation fails: success comes back false and errorMessage explains the failure. The workbook is never partially unlocked and your source file is never modified.
Does unlocking change the workbook contents?+
No. Cells, formulas, formatting, and sheets are untouched. Only the protection layers are removed; the output is the same workbook without the locks.
How do I keep the password out of my scripts?+
Inject it at runtime: a Postman environment variable, an environment variable in shell scripts, or a secrets manager in production code. Request bodies frequently end up in logs and version control, so treat the payload as sensitive.
Can I re-protect the file after processing?+
Yes. Chain the Secure Excel action after your processing steps to apply fresh protection to the finished workbook.

为什么通过解锁 API 而不是手动操作?

手动进行纸张级锁扣的路线是 揭开床单的保护膜 Excel打开文件,输入密码,点击“审阅”选项卡,取消保护工作表,保存,对每个文件重复此操作。这种方法无法扩展到包含受保护报告的夜间文件夹。 API 执行与每个文件一次确定性请求相同的密码验证删除操作,输出保持标准格式。 办公室开放 XML 工作簿已准备就绪,可供后续流程使用。

相关行动

在其他平台上执行相同的任务

获取帮助