Skip to main content

Secure Document - Excel API

PDF4me Secure Excel enables you to apply password protection to Excel documents at multiple levels. This API service supports file encryption (password to open), workbook structure protection (prevent sheet modifications), and worksheet content protection (prevent cell edits), with flexible password hierarchy and protection types (Contents, Objects, Scenarios, All). The API receives Excel document content through REST API calls, utilizing Base64 encoding for secure transmission. This solution is ideal for confidential data protection, template security, and controlled access workflows.

Related Blog Posts
No blog post yet for this feature — coming soon.
In the meantime, browse the PDF4me blog for tutorials and workflows across every platform.
Visit the blog →

Authenticating Your API Request​

Include your API key in the request to authenticate with the PDF4me REST API.

Key Features​

  • Three Protection Levels: File encryption, workbook structure, worksheet content
  • Independent Passwords: Use different passwords for each protection level
  • Password Fallback: Use main password as fallback when level-specific password not provided
  • Flexible Worksheet Selection: Protect specific worksheets or all worksheets
  • Protection Type Options: Contents, Objects, Scenarios, or All (comprehensive)
  • 0-Based Indexing: Worksheet indexes use 0-based numbering (0 = first worksheet)

REST API Endpoint​

  • Method: POST
  • Endpoint: office/ApiV2Excel/ExcelSecure

REST API Parameters​

Important: Parameters marked with an asterisk (*) are required. All requests use document, docContent, and secureExcelAction. Operation-specific parameters (password, protectWorkbook, etc.) are properties of the action object.

Required Parameters (root level)​

ParameterRequiredWhat it doesExample
documentRequiredSource file. `Name` must end in `.xlsx`, `.xls` or `.xlsm` (a `.csv` for `ExcelParseCsv`).{ "Name": "data.xlsx" }
document.NameRequiredFile name including its extension. Type: string.{ "Name": "data.xlsx" }
docContentRequiredThe source file, base64-encoded. Type: string.UEsDBBQABgAIAAAA...
isAsyncOptionalProcess the request in the background. The call returns `202 Accepted`; poll the `Location` URL (`GetActionStatus`) for the result. Type: boolean.
secureExcelActionRequiredObject carrying this operation's settings. Its fields are the secureExcelAction rows below.See Payload example below
secureExcelAction.passwordOptionalPassword required to open the file. Also used for the sheets when `worksheetProtectionPassword` is not set. Type: string.
secureExcelAction.protectWorkbookOptionalProtect the workbook structure. Type: boolean.
secureExcelAction.protectWorkbookPasswordOptionalPassword for the workbook structure. Type: string.
secureExcelAction.protectWorksheetsOptionalProtect the sheets from editing. Type: boolean.
secureExcelAction.worksheetProtectionTypeOptionalType: string.
secureExcelAction.worksheetProtectionPasswordOptionalPassword for the sheets. Type: string.
secureExcelAction.worksheetNamesOptionalComma-separated worksheet names. Type: string.
secureExcelAction.worksheetIndexesOptionalComma-separated 1-based worksheet numbers, e.g. `"1,3"`. Type: string.

Output​

The API returns the password-protected Excel document as a Base64-encoded string in JSON format (document, fileName, success, errorMessage).

Request Example​

Content-Type: application/json
Authorization: Basic YOUR_BASE64_ENCODED_API_KEY

Payload (Basic)​

{
"document": { "Name": "data.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"secureExcelAction": {
"password": "MyPassword123",
"protectWorkbook": true,
"protectWorksheets": true
}
}

Code Samples​

Get Help​