Passa al contenuto principale

Aggiorna righe in Excel

PDF4me Aggiorna righe è un REST punto finale che scrive JSON dati in righe esistenti di un Excel cartella di lavoro. POST il file .xlsx come Base64 A office/ApiV2Excel/ExcelUpdateRows con i tuoi dati in jsonInput, righe di destinazione per Excel nome della tabella o tramite coordinate basate su 1, quindi decodificare la cartella di lavoro aggiornata da JSON risposta. La conversione numerica e di data è automatica per impostazione predefinita.

Cosa fa questo endpoint

Prende un quaderno di lavoro più un JSON array di oggetti e scrive quei valori nelle righe esistenti: prezzi aggiornati in un listino prezzi, record corretti in un report, campi sincronizzati dal tuo CRM. Scegli dove vengono indirizzati i dati con una delle due modalità di targeting, una denominata Excel tabella o coordinate esatte di riga e colonna. La risposta è JSON con la cartella di lavoro aggiornata come Base64 contenuto.

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/ExcelUpdateRows

Informazioni importanti da non perdere

jsonInput è una stringa, non un JSON vettore
I dati di aggiornamento viaggiano come un carattere di escape JSON corda all'interno jsonInputL'invio di un array non elaborato è la causa più comune di un errore 400 su questo endpoint. Serializzare prima, poi incorporare.
Due modalità di targeting, scelte da tableName
Un non vuoto nometabella passa alla modalità tavolo con excelRowNumber; uno vuoto significa modalità coordinate con insertFromRow/insertFromColumnTutte le posizioni sono basate su 1.
La risposta è Base64 JSON, non il file
La cartella di lavoro aggiornata viene restituita come un Base64 corda all'interno di un JSON corpo con fileName, success, E messaggio di erroreDecodifica il file prima di salvarlo; la risposta non elaborata non è un file .xlsx valido.

HTTP impostare

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

La risposta è JSON: controlla il success bandiera, poi Base64-decodifica il contenuto della cartella di lavoro restituita e salvalo con un .xlsx estensione.

Devo usare la modalità tabella o la modalità coordinate?

Le due modalità supportano layout di foglio di calcolo diversi e la scelta di quella sbagliata è la causa più comune per cui un aggiornamento finisce nelle celle errate.

Modalità tabella vs modalità coordinateModalità tavoloModalità coordinate
Come selezionarloImpostato tableName a un nominato Excel tavoloPartire tableName vuoto
Dove atterrano i datiRiga excelRowNumber all'interno della tabella (in base 1)A partire da insertFromRow/insertFromColumn (Base 1, quindi 1/1 è A1)
Corrispondenza colonnaJSON i nomi delle proprietà corrispondono alle intestazioni delle colonne della tabellaI valori sono scritti da sinistra a destra a partire dalla colonna iniziale.
Resiste ai cambiamenti di layoutSì, l'aggiornamento segue la tabella se si spostaNo, le coordinate sono posizioni fisse
Ideale perFogli di lavoro strutturati con effetti reali Excel tavoliSchede semplici e fogli ad hoc

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 update.UEsDBBQABgAIAAAA...
updateRowsToExcelActionRequiredobjectAction configuration object holding jsonInput and all targeting options below.{ "jsonInput": "..." }
jsonInputRequiredstringInside the action object. A STRING containing an escaped JSON array of objects; property names become column targets in table mode."[{\"Name\":\"John\",\"Age\":31}]"
worksheetNameOptionalstringInside the action object. Target worksheet; defaults to the first sheet when omitted.Sheet1
tableNameConditionalstringInside the action object. Names the Excel table for table mode. Empty or omitted switches the action to coordinate mode.SalesTable
excelRowNumberConditionalnumberInside the action object. Table mode only: the 1-based row position within the table to update.5
insertFromRowConditionalnumberInside the action object. Coordinate mode only: the 1-based worksheet row where writing starts.10
insertFromColumnConditionalnumberInside the action object. Coordinate mode only: the 1-based worksheet column where writing starts.1
convertNumericAndDateOptionalbooleanInside the action object. true (default) writes numeric-looking and date-looking values as real Excel numbers and dates instead of text.true
cultureNameOptionalstringInside the action object. Culture used to parse dates and numbers, for example en-US or de-DE. Pair with convertNumericAndDate.en-US

Esempi di carichi utili

Modalità tabella: aggiorna la riga 5 di una tabella denominata

{
"document": { "Name": "sales.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"updateRowsToExcelAction": {
"jsonInput": "[{\"Region\":\"EMEA\",\"Revenue\":125000}]",
"worksheetName": "Q3",
"tableName": "SalesTable",
"excelRowNumber": 5
}
}

Modalità coordinate: scrittura a partire dalla cella A10

{
"document": { "Name": "data.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"updateRowsToExcelAction": {
"jsonInput": "[{\"Name\":\"John\",\"Age\":31},{\"Name\":\"Ana\",\"Age\":28}]",
"insertFromRow": 10,
"insertFromColumn": 1,
"convertNumericAndDate": true,
"cultureName": "en-US"
}
}

Consigli per la raccolta del postino

Headers
Content-Type: application/json + Authorization: Basic <apiKey>.
Body
raw JSON. jsonInput must be a string: escape the inner quotes or use your HTTP library to serialize the array first, then assign it as a string.
Targeting
tableName set = table mode with excelRowNumber. tableName empty = coordinate mode with insertFromRow/insertFromColumn. Both are 1-based.
Response
JSON with a success flag and Base64 workbook content. Decode the document field before saving as .xlsx.

esempio di riccio

curl -X POST https://api.pdf4me.com/office/ApiV2Excel/ExcelUpdateRows \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"document": { "Name": "data.xlsx" },
"docContent": "'"$(base64 -w 0 data.xlsx)"'",
"updateRowsToExcelAction": {
"jsonInput": "[{\"Name\":\"John\",\"Age\":31}]",
"insertFromRow": 10,
"insertFromColumn": 1
}
}' \
--output response.json

Che cosa significa il API ritorno?

UN JSON risultato che porta la cartella di lavoro aggiornata come Base64.

CampoTipoCosa contiene
documentString (Base64)The updated workbook content. Decode to bytes and save with an .xlsx extension.
fileNameStringOutput filename for the updated workbook.
successBooleantrue when the update succeeded. Check this before decoding content.
errorMessageStringPopulated when success is false: malformed jsonInput, a missing table or worksheet, or invalid Base64.

L'output rimane standard Ufficio aperto XML cartella di lavoro, quindi formule, formattazione e fogli al di fuori delle celle aggiornate rimangono invariati.

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 does the API reject my jsonInput with a 400 error?+
jsonInput is a string field that contains JSON, so the inner quotes must be escaped. Sending a raw JSON array instead of a string-encoded one is the most common cause of a 400 Bad Request on this endpoint.
Should I use table mode or coordinate mode?+
Use table mode (tableName plus excelRowNumber) when the worksheet has a named Excel table: the update follows the table even if it moves. Use coordinate mode (insertFromRow and insertFromColumn, tableName empty) for plain ranges at fixed positions.
Are the row and column numbers 0-based or 1-based?+
1-based. insertFromRow 1 and insertFromColumn 1 address cell A1, and excelRowNumber 1 is the first data row of the table. This differs from some other PDF4me Excel actions where worksheet indexes are 0-based.
Is the response the Excel file itself?+
No. The API returns JSON containing the updated workbook as a Base64 string plus fileName, success, and errorMessage fields. Decode the document field to bytes before saving as .xlsx.
How are numbers and dates handled?+
convertNumericAndDate defaults to true, so values that look like numbers or dates are written as real Excel numbers and dates rather than text. Pair it with cultureName so formats like 31.12.2026 or 12/31/2026 parse correctly.
What is the difference between Update Rows and Add Rows?+
Update Rows overwrites values in rows that already exist at the targeted position. Add Rows appends or inserts new rows. If you point Update Rows at empty cells it simply writes the values there; it does not shift existing data down.
Can I update rows in a protected workbook?+
No. Protection blocks editing. Chain the Unlock Excel action first with the correct password, run the update, then re-apply protection with Secure Excel Document if needed.

Perché aggiornare Excel righe tramite API invece che manualmente?

Il percorso manuale consiste nell'aprire ogni cartella di lavoro, trovare le righe, riscrivere i valori e salvare: fattibile una volta, non fattibile per una sincronizzazione notturna da un CRM o database. Il API esegue la stessa modifica di una richiesta deterministica per file, mantiene Excel tavoli intatto e non ha mai bisogno Excel installato sul server. L'output è uno standard Ufficio aperto XML Cartella di lavoro pronta per la fase successiva del processo.

Azioni correlate

Stessa attività su altre piattaforme

Richiedi assistenza