Lewati ke konten utama

Perbarui Baris di Excel

PDF4me Perbarui Baris adalah sebuah REST titik akhir yang menulis JSON memasukkan data ke dalam baris yang sudah ada di Excel buku kerja. POST file .xlsx sebagai Base64 ke office/ApiV2Excel/ExcelUpdateRows dengan data Anda di jsonInput, baris target berdasarkan Excel nama tabel atau berdasarkan koordinat berbasis 1, kemudian dekode buku kerja yang diperbarui dari JSON respons. Konversi angka dan tanggal otomatis secara default.

Fungsi dari endpoint ini

Membutuhkan buku kerja ditambah sebuah JSON array objek dan menulis nilai-nilai tersebut ke dalam baris yang sudah ada: harga yang diperbarui dalam daftar harga, catatan yang dikoreksi dalam laporan, bidang yang disinkronkan dari Anda CRMAnda memilih ke mana data tersebut akan ditempatkan dengan salah satu dari dua mode penargetan, yaitu penargetan bernama. Excel tabel atau koordinat baris dan kolom yang tepat. Jawabannya adalah JSON dengan buku kerja yang diperbarui sebagai Base64 isi.

Postingan Blog Terkait
Belum ada postingan blog untuk fitur ini — akan segera hadir.
Sementara itu, jelajahi blog PDF4me untuk menemukan tutorial dan alur kerja di berbagai platform.
Kunjungi blog ini

Memverifikasi Identitas Anda API Meminta

Setiap PDF4me REST panggilan harus menyertakan Anda API kunci di Authorization Header sebagai otentikasi Dasar. Dapatkan atau putar kunci Anda dari dasbor pengembang.

Titik akhir

POSToffice/ApiV2Excel/ExcelUpdateRows

Fakta Penting yang Tidak Boleh Anda Lewatkan

jsonInput adalah sebuah string, bukan sebuah JSON susunan
Data pembaruan dikirim sebagai data yang lolos JSON string di dalam input jsonMengirim array mentah ke sana adalah penyebab paling umum terjadinya error 400 pada endpoint ini. Lakukan serialisasi terlebih dahulu, kemudian sematkan.
Dua mode penargetan, dipilih berdasarkan nama tabel.
Tidak kosong nama tabel beralih ke mode tabel dengan excelRowNumber; yang kosong berarti mode koordinat dengan sisipkanDariBaris/sisipkanDariKolomSemua posisi berbasis 1.
Jawabannya adalah Base64 JSON, bukan file
Buku kerja yang diperbarui kembali hadir sebagai Base64 tali di dalam JSON tubuh dengan fileName, success, Dan pesan kesalahan. Dekode sebelum menyimpan; respons mentah bukanlah file .xlsx yang valid.

HTTP pengaturan

Metode: POST
URL: https://api.pdf4me.com/office/ApiV2Excel/ExcelUpdateRows
Tipe Konten: aplikasi/json
Authorization: Dasar <Anda PDF4me API kunci>

Jawabannya adalah... JSON: periksa success bendera, lalu Base64-mendekode konten buku kerja yang dikembalikan dan menyimpannya dengan sebuah .xlsx Ekstensi.

Apakah saya harus menggunakan mode tabel atau mode koordinat?

Kedua mode tersebut melayani tata letak lembar kerja yang berbeda, dan memilih mode yang salah biasanya menjadi alasan mengapa pembaruan masuk ke sel yang salah.

Mode tabel vs mode koordinatMode tabelMode koordinat
Bagaimana cara memilihnya?Mengatur tableName kepada seseorang yang bernama Excel mejaMeninggalkan tableName kosong
Ke mana data tersebut berakhirBaris excelRowNumber di dalam tabel (berbasis 1)Dimulai dari insertFromRow/insertFromColumn (Berbasis 1, jadi 1/1 adalah A1)
Pencocokan kolomJSON Nama properti dipetakan ke judul kolom tabel.Nilai ditulis dari kiri ke kanan mulai dari kolom awal.
Bertahan terhadap perubahan tata letakYa, pembaruan akan mengikuti tabel jika tabel tersebut bergeser.Tidak, koordinat adalah posisi tetap.
Terbaik untukLembar kerja terstruktur dengan contoh nyata Excel tabelRentang polos dan lembar ad-hoc

API bidang tubuh

ParameterDiperlukanJenisApa fungsinya?Contoh
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

Contoh muatan

Mode tabel: perbarui baris 5 dari tabel bernama

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

Mode koordinat: tulis mulai dari sel 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"
}
}

Tips pengambilan oleh tukang pos

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.

contoh curl

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

Apa arti dari API kembali?

A JSON hasil yang membawa buku kerja yang telah diperbarui sebagai Base64.

BidangJenisIsi di dalamnya
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.

Outputnya tetap standar. Kantor Buka XML buku kerja, sehingga rumus, pemformatan, dan lembar kerja di luar sel yang diperbarui tidak terpengaruh.

Contoh kode

Excel Perangkat ujung kantor belum tercakup oleh per-language folder sampel; repositori sampel membawa pola permintaan yang digunakan oleh setiap PDF4me keluarga titik akhir:

Pertanyaan yang Sering Diajukan (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.

Mengapa memperbarui? Excel baris melalui API alih-alih secara manual?

Cara manualnya adalah membuka setiap buku kerja, mencari baris yang diinginkan, mengetik ulang nilainya, dan menyimpan: cara ini efektif sekali, tetapi tidak efektif untuk sinkronisasi harian. CRM atau basis data. Itu API melakukan pengeditan yang sama seperti satu permintaan deterministik per file, mempertahankan Excel tabel utuh, dan tidak pernah membutuhkan Excel terpasang di server. Outputnya standar. Kantor Buka XML Buku kerja siap untuk langkah selanjutnya dalam alur kerja.

Tindakan terkait

Tugas yang sama di platform lain

Dapatkan Bantuan