Saltar al contenido principal

Extraer filas de Excel

PDF4me Extraer filas es un REST punto final que lee filas de la hoja de cálculo desde un Excel libro de trabajo y los devuelve como estructurados JSON. POST el .xlsx como Base64 a office/ApiV2Excel/ExcelExtractRows, delimitar el rango de la hoja de cálculo y de filas en el objeto de acción y consumir el rowData Matriz. Devuelve datos, no un archivo: document devuelve nulo.

Lo que hace este punto final

Convierte una porción de hoja de cálculo en una JSON matriz: cada fila se convierte en un objeto en datos de fila, listo para una inserción en la base de datos, un API llamada o un informe. Es la contraparte de solo lectura de Agregar filas y Actualizar filas, y el API-equivalente lateral de exportación Excel datos sin abrir ExcelNo se genera ningún archivo modificado.

Entradas de blog relacionadas
Aún no hay ninguna entrada de blog sobre esta función; estará disponible próximamente.
Mientras tanto, echa un vistazo al blog de PDF4me para encontrar tutoriales y flujos de trabajo para todas las plataformas.
Visita el blog

Autenticando su API Pedido

Cada PDF4me REST La llamada debe incluir su API clave en el Authorization Encabezado como autenticación básica. Obtenga o cambie su clave desde el panel de desarrollador.

Punto final

POSTOffice/ApiV2Excel/ExtraerFilas de Excel

Datos importantes que no debes perderte

rowData es la salida, los campos del archivo son nulos.
Este punto final devuelve datos, no un libro de trabajo modificado. documento y fileName devolver nulo por diseño; código que espera un Base64 El archivo allí se romperá.
El motor cuenta las filas desde 0.
La fila 0 es Excel fila 1, y -1 significa a la última fila de datos, la misma semántica n8n Documentos de acción para extraer filas para este motor. Los rangos con un desfase de uno son la principal pregunta de soporte.
Solo lectura: su libro de trabajo permanece intacto.
La extracción analiza el archivo y serializa las filas en JSONNo se guarda ninguna información, por lo que es seguro ejecutarlo en libros de trabajo y archivos de producción.

HTTP configuración

Método: POST
URL: https://api.pdf4me.com/office/ApiV2Excel/ExcelExtractRows
Tipo de contenido: aplicación/json
Authorization: Básico <tu PDF4me API clave>

La respuesta es JSON: comprobar el success bandera, luego iterar la datos de fila Matriz. No hay ningún archivo para decodificar.

¿En qué se diferencia Extraer filas de las demás? Excel ¿Acciones de fila?

La familia de filas abarca las operaciones de escritura, sobrescritura y lectura. Seleccione según lo que deba suceder con el libro de trabajo.

Acción versus comportamientoQué efecto tiene en el libro de trabajoLo que recibes a cambio
Extraer filas (este punto final)Nada, solo lecturaA rowData JSON matriz, un objeto por fila
Agregar filasAgrega o inserta nuevas filas.El libro de trabajo modificado como Base64
Actualizar filasSobrescribe los valores de las filas existentes.El libro de trabajo modificado como Base64
Eliminar filasElimina filasEl libro de trabajo modificado como Base64

API campos corporales

ParámetroRequeridoTipoLo que haceEjemplo
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

Cargas útiles de ejemplo

Lea la hoja de cálculo predeterminada

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

Lee una hoja de trabajo con nombre y valores que tengan en cuenta la cultura.

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

Consejos para el cobro de carteros

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.

Ejemplo de 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

¿Qué significa el API ¿devolver?

A JSON resultado cuya carga útil es la rowData matriz.

CampoTipoLo que contiene
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" }
]
}

Ejemplos de código

Excel Los puntos finales de la oficina aún no están cubiertos por per-language carpetas de muestra; el repositorio de muestras contiene el patrón de solicitud utilizado por cada PDF4me familia de puntos finales:

Preguntas frecuentes

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.

¿Por qué extraer? Excel regalado API ¿En lugar de hacerlo manualmente?

La ruta manual consiste en abrir el libro de trabajo, seleccionar el rango, copiarlo en algún lugar y redimensionarlo manualmente, una vez por archivo, por cada actualización. API lee las mismas filas que una solicitud determinista y te entrega JSON que cualquier language analiza de forma nativa, sin Excel instalación en el servidor. Porque la fuente sigue siendo estándar Oficina abierta XML El libro de trabajo y la operación son de solo lectura, pero la misma llamada se puede ejecutar de forma segura según un cronograma en archivos en vivo.

Acciones relacionadas

La misma tarea en otras plataformas.

Obtén ayuda