跳到主要内容

Excel

PDF4me 提取行 是一个 REST 从工作表中读取行的端点 Excel 工作簿并将其以结构化形式返回。 JSONPOST 将 .xlsx 文件作为 Base64office/ApiV2Excel/ExcelExtractRows在操作对象中限定工作表和行范围,并使用该操作。 rowData 返回的是数据,而不是文件: document 返回空值。

此端点的作用

将工作表切片转换为 JSON 数组:每一行都成为一个对象 行数据准备进行数据库插入,一个 API 调用或报告。它是“添加行”和“更新行”的只读对应项,并且 API出口的等效项 Excel 无需打开即可获取数据 Excel不会生成修改后的文件。

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

验证您的身份 API 要求

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

端点

POSToffice/ApiV2Excel/ExcelExtractRows

您不容错过的重要事实

rowData 是输出结果,文件字段为空。
此端点返回数据,而不是修改后的工作簿。 文档fileName 本意是返回 null;代码期望返回 null。 Base64 那里的文件会损坏。
引擎从第 0 行开始计数。
第 0 行是 Excel 第 1 行,-1 表示到最后一行数据,语义相同。 n8n 提取此引擎的行操作文档。差一范围是用户最常问的支持问题。
只读:您的工作簿未被修改
提取过程解析文件并将行序列化为 JSON不会有任何数据写回,因此可以安全地对生产工作簿和归档文件运行。

HTTP 设置

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

回答是 JSON检查 success 标志,然后迭代 行数据 数组。没有文件需要解码。

提取行与其他操作有何不同? Excel 行操作?

行族涵盖写入、覆盖和读取操作。根据工作簿应执行的操作进行选择。

行动与行为它对练习册的影响你得到的回报
提取行(此端点)无,只读A rowData JSON 数组,每行一个对象
添加行追加或插入新行修改后的工作簿 Base64
更新行覆盖现有行中的值修改后的工作簿 Base64
删除行删除行修改后的工作簿 Base64

API 身体场

范围必需的类型它的作用例子
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

示例有效载荷

阅读默认工作表

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

阅读一份包含文化意识价值观的指定工作表

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

邮递员收款小贴士

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 示例

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

什么 API 返回?

A JSON 结果的有效载荷是 rowData 大批。

场地类型它包含什么
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" }
]
}

代码示例

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

常问问题

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.

为什么要提取 Excel 赠送 API 而不是手动操作?

手动操作方法是打开工作簿,选择区域,将其复制到其他位置,然后手动调整其格式,每个文件每次刷新都需要这样做。 API 读取与一个确定性请求相同的行,并将结果返回给你。 JSON 任何 language 原生解析,无 Excel 在服务器上安装。因为源代码保持标准。 办公室开放 XML 工作簿和操作是只读的,因此可以安全地按计划对实时文件运行相同的调用。

相关行动

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

获取帮助