Passa al contenuto principale

Estrai righe da Excel

PDF4me Estrai righe è un REST punto finale che legge le righe del foglio di lavoro da un Excel cartella di lavoro e li restituisce in formato strutturato JSON. POST il file .xlsx come Base64 A office/ApiV2Excel/ExcelExtractRows, definire l'ambito del foglio di lavoro e dell'intervallo di righe nell'oggetto azione e consumare il rowData Restituisce dati, non un file: document restituisce null.

Cosa fa questo endpoint

Trasforma una porzione di foglio di lavoro in un JSON array: ogni riga diventa un oggetto in dati riga, pronto per un inserimento nel database, un API chiamata o un report. È la controparte di sola lettura di Aggiungi righe e Aggiorna righe e il API-equivalente laterale dell'esportazione Excel dati senza apertura ExcelNon viene prodotto alcun file modificato.

Articoli correlati del blog
Non ci sono ancora post sul blog dedicati a questa funzionalità — in arrivo a breve.
Nel frattempo, dai un'occhiata al blog di PDF4me per trovare tutorial e procedure operative su tutte le piattaforme.
Visita il blog

Autenticazione del tuo API Richiesta

Ogni PDF4me REST la chiamata deve includere il tuo API chiave nel Authorization Intestazione come autenticazione di base. Ottieni o ruota la tua chiave dalla dashboard dello sviluppatore.

Punto finale

POSTufficio/ApiV2Excel/ExcelExtractRows

Informazioni importanti da non perdere

rowData è l'output, i campi del file sono nulli
Questo endpoint restituisce dati, non una cartella di lavoro modificata. documento E fileName tornare nullo per impostazione predefinita; codice che si aspetta un Base64 Il file lì presente si romperà.
Il motore conta le righe in base 0
La riga 0 è Excel riga 1 e -1 significa all'ultima riga di dati, la stessa semantica n8n Documenti di azione per l'estrazione delle righe per questo motore. Gli intervalli con differenza di uno sono la domanda di supporto più frequente.
Sola lettura: la cartella di lavoro rimane invariata.
L'estrazione analizza il file e serializza le righe in JSONNon viene scritto nulla, quindi è possibile eseguirlo in sicurezza su cartelle di lavoro e archivi di produzione.

HTTP impostare

Metodo: POST
URL: https://api.pdf4me.com/office/ApiV2Excel/ExcelExtractRows
Tipo di contenuto: applicazione/json
Authorization: Base <il tuo PDF4me API chiave>

La risposta è JSON: controlla il success bandiera, quindi itera il dati riga array. Non c'è alcun file da decodificare.

In che modo Extract Rows si differenzia dagli altri? Excel azioni di riga?

La famiglia di righe copre le operazioni di scrittura, sovrascrittura e lettura. Scegli in base a cosa deve accadere alla cartella di lavoro.

Azione contro comportamentoCosa fa alla cartella di lavoroCiò che ricevi indietro
Estrai righe (questo endpoint)Niente, sola letturaUN rowData JSON array, un oggetto per riga
Aggiungi righeAggiunge o inserisce nuove righeLa cartella di lavoro modificata come Base64
Aggiorna righeSovrascrive i valori nelle righe esistentiLa cartella di lavoro modificata come Base64
Elimina righeRimuove le righeLa cartella di lavoro modificata come Base64

API campi corporei

ParametroNecessarioTipoCosa faEsempio
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

Esempi di carichi utili

Leggi il foglio di lavoro predefinito

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

Leggi un foglio di lavoro denominato con valori culturalmente sensibili

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

Consigli per la raccolta del postino

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.

esempio di riccio

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

Che cosa significa il API ritorno?

UN JSON risultato il cui payload è il rowData vettore.

CampoTipoCosa 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" }
]
}

Esempi di codice

Excel Gli endpoint dell'ufficio non sono ancora coperti da per-language cartelle di esempio; il repository degli esempi contiene il modello di richiesta utilizzato da ogni PDF4me Famiglia di endpoint:

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.

Perché estrarre Excel data via API invece che manualmente?

Il metodo manuale consiste nell'aprire la cartella di lavoro, selezionare l'intervallo, copiarlo da qualche parte e rimodellarlo manualmente, una volta per file, ad ogni aggiornamento. API legge le stesse righe di una richiesta deterministica e ti consegna JSON che qualsiasi language analizza in modo nativo, senza Excel installazione sul server. Poiché la sorgente rimane uno standard Ufficio aperto XML La cartella di lavoro e l'operazione sono di sola lettura, la stessa chiamata può essere eseguita in sicurezza in base a una pianificazione su file di produzione.

Azioni correlate

Stessa attività su altre piattaforme

Richiedi assistenza