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.

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)

ParameterTypeDescriptionExample
document*ObjectDocument reference with Name (Excel file name){ "Name": "data.xlsx" }
docContent*String (Base64)Excel document content encoded in Base64UEsDBBQABgAIAAAA...
secureExcelAction*ObjectAction configuration (password, protection levels, worksheet selection)See Payload example below

Optional Parameters (inside secureExcelAction)

ParameterTypeDescriptionExample
passwordStringFile encryption password (Level 1). Also used as fallback for workbook/worksheet protection if their passwords are emptyMyPassword123
protectWorkbookBooleanEnable workbook structure protection (Level 2). Default: falsetrue
protectWorkbookPasswordStringWorkbook protection password. Fallback: password if emptyStructurePass
protectWorksheetsBooleanEnable worksheet content protection (Level 3). Default: falsetrue
worksheetProtectionTypeStringContents, Objects, Scenarios, or All. Default: AllAll
worksheetProtectionPasswordStringWorksheet protection password. Fallback: password if emptyEditPass
worksheetNamesStringComma-separated worksheet names to protect; empty = allSheet1,Summary
worksheetIndexesStringComma-separated worksheet indexes (0-based); empty = all0,2
cultureNameStringCulture code for processingen-US

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