Skip to main content

Extract Rows from Excel

PDF4me Extract Rows is a REST endpoint that reads worksheet rows out of an Excel workbook and returns them as structured JSON. POST the .xlsx as Base64 to office/ApiV2Excel/ExcelExtractRows, scope the worksheet and row range in the action object, and consume the rowData array. It returns data, not a file: document comes back null.

What this endpoint does

Turns a worksheet slice into a JSON array: each row becomes one object in rowData, ready for a database insert, an API call, or a report. It is the read-only counterpart to Add Rows and Update Rows, and the API-side equivalent of exporting Excel data without opening Excel. No modified file is produced.

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

Every PDF4me REST call must include your API key in the Authorization header as Basic auth. Get or rotate your key from the developer dashboard.

Endpoint

POSToffice/ApiV2Excel/ExcelExtractRows

Important Facts You Should Not Miss

rowData is the output, the file fields are null
This endpoint returns data, not a modified workbook. document and fileName come back null by design; code that expects a Base64 file there will break.
The engine counts rows 0-based
Row 0 is Excel row 1, and -1 means to the last data row, the same semantics the n8n Extract Rows action documents for this engine. Off-by-one ranges are the top support question.
Read-only: your workbook is untouched
Extraction parses the file and serializes rows to JSON. Nothing is written back, so it is safe to run against production workbooks and archives.

HTTP setup

Method: POST
URL: https://api.pdf4me.com/office/ApiV2Excel/ExcelExtractRows
Content-Type: application/json
Authorization: Basic <your PDF4me API key>

The response is JSON: check the success flag, then iterate the rowData array. There is no file to decode.

How is Extract Rows different from the other Excel row actions?

The row family covers write, overwrite, and read. Pick by what should happen to the workbook.

Action vs behaviorWhat it does to the workbookWhat you get back
Extract Rows (this endpoint)Nothing, read-onlyA rowData JSON array, one object per row
Add RowsAppends or inserts new rowsThe modified workbook as Base64
Update RowsOverwrites values in existing rowsThe modified workbook as Base64
Delete RowsRemoves rowsThe modified workbook as Base64

API body fields

ParameterRequiredTypeWhat it doesExample
documentRequiredobjectDocument reference carrying Name, the Excel filename with its extension.{ "Name": "data.xlsx" }
docContentRequiredstringBase64-encoded bytes of the workbook to read.UEsDBBQABgAIAAAA...
extractRowsToExcelActionRequiredobjectAction configuration object. An empty object is valid and reads the default worksheet.{}
worksheetNameOptionalstringInside the action object. Target worksheet by name. Names are matched exactly, so a typo silently misses the sheet.Sheet1
worksheetIndexOptionalnumberInside the action object. Target worksheet by position. The extraction engine counts 0-based, so 0 is the first sheet.0
fromRow / toRowOptionalnumberInside the action object. Row range to extract. The engine counts rows 0-based with -1 meaning to the last data row, per the shared engine documented on the n8n Extract Rows action.0, -1
cultureNameOptionalstringInside the action object. Culture used when serializing dates and numbers, for example en-US or de-DE.en-US

Sample payloads

Read the default worksheet

{
"document": { "Name": "data.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"extractRowsToExcelAction": {}
}

Read a named worksheet with culture-aware values

{
"document": { "Name": "sales.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"extractRowsToExcelAction": {
"worksheetName": "Q3",
"cultureName": "en-US"
}
}

Postman collection tips

Headers
Content-Type: application/json + Authorization: Basic <apiKey>.
Body
raw JSON. extractRowsToExcelAction may be an empty object {}; worksheet targeting and ranges are optional narrowing.
Response
Plain JSON. Assert on rowData, not on document: the file fields are null for this endpoint by design.
Ranges
The engine counts rows 0-based and treats -1 as "to the last data row". Test with a small explicit range first.

curl example

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

What does the API return?

A JSON result whose payload is the rowData array.

FieldTypeWhat it contains
rowDataArray of objectsThe primary output. Each entry is one extracted row as a JSON object, with column names or indexes as keys.
successBooleantrue when extraction succeeded. Check this before iterating rowData.
documentnullNull for this endpoint: no modified file is produced. Present only because the office family shares one response shape.
fileNamenullNull for this endpoint, for the same reason as document.
errorMessageStringPopulated when success is false: a missing worksheet, invalid Base64, or a corrupted workbook.
{
"document": null,
"fileName": null,
"success": true,
"errorMessage": null,
"rowData": [
{ "ColumnA": "value1", "ColumnB": "value2" },
{ "ColumnA": "value3", "ColumnB": "value4" }
]
}

Code samples

Excel office endpoints are not yet covered by per-language sample folders; the samples repository carries the request pattern used by every PDF4me endpoint family:

FAQ

Why are document and fileName null in the response?+
Because Extract Rows returns data, not a modified workbook. The primary output is the rowData array of row objects; the file-oriented fields exist in the shared response shape but stay null for this endpoint.
Are row indexes 0-based or 1-based?+
The extraction engine behind this action counts rows and columns 0-based, so row 0 is Excel row 1, and -1 means read to the last data row or column. If your range seems off by one, this is why.
Can I pipe the output into a database or another API?+
Yes, that is the point of the endpoint. rowData is plain JSON: each array entry is one row as an object, ready for an INSERT statement, an HTTP POST, or any downstream transformation.
What happens if I send an empty action object?+
The action still runs: the API reads the default worksheet and returns its rows. Add worksheetName or a row range only when you need to narrow the extraction.
Does this endpoint modify my Excel file?+
No. It is read-only. The source workbook is parsed, the rows are serialized to JSON, and no modified file is produced or returned.
Can I read a password-protected workbook?+
No. Protection blocks parsing. Chain the Unlock Excel action first with the correct password, then extract from the unlocked copy.
How do I extract whole worksheets instead of rows?+
Use the Extract Worksheets action, which splits worksheets out of the workbook. Extract Rows is for reading row values as JSON; Extract Worksheets is for separating sheets as workbook content.

Why extract Excel data via API instead of manually?

The manual route is opening the workbook, selecting the range, copying it somewhere, and reshaping it by hand, once per file, per refresh. The API reads the same rows as one deterministic request and hands you JSON that any language parses natively, with no Excel installation on the server. Because the source stays a standard Office Open XML workbook and the operation is read-only, the same call is safe to run on a schedule against live files.

Same task on other platforms

Get Help