Lewati ke konten utama

Ekstrak Baris dari Excel

PDF4me Ekstrak Baris adalah sebuah REST titik akhir yang membaca baris lembar kerja dari sebuah Excel buku kerja dan mengembalikannya sesuai struktur yang telah disusun. JSON. POST file .xlsx sebagai Base64 ke office/ApiV2Excel/ExcelExtractRows, tentukan cakupan lembar kerja dan rentang baris dalam objek tindakan, dan gunakan rowData array. Fungsi ini mengembalikan data, bukan file: document hasilnya null.

Fungsi dari endpoint ini

Mengubah potongan lembar kerja menjadi sebuah JSON array: setiap baris menjadi satu objek di data baris, siap untuk penyisipan ke dalam basis data, sebuah API panggilan, atau laporan. Ini adalah versi baca-saja dari Tambah Baris dan Perbarui Baris, dan API-setara dengan ekspor sisi kanan Excel data tanpa membuka ExcelTidak ada file yang dimodifikasi yang dihasilkan.

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

POSTkantor/ApiV2Excel/ExcelExtractRows

Fakta Penting yang Tidak Boleh Anda Lewatkan

rowData adalah output, kolom file bernilai null.
Endpoint ini mengembalikan data, bukan buku kerja yang telah dimodifikasi. dokumen Dan fileName kembali null sesuai desain; kode yang mengharapkan Base64 File di sana akan rusak.
Mesin menghitung baris berbasis 0.
Baris 0 adalah Excel baris 1, dan -1 berarti ke baris data terakhir, semantik yang sama. n8n Ekstrak dokumen tindakan Baris untuk mesin ini. Rentang selisih satu angka adalah pertanyaan dukungan teratas.
Hanya baca: buku kerja Anda tidak diubah
Proses ekstraksi menguraikan file dan menserialisasi baris ke JSONTidak ada yang ditulis kembali, jadi aman untuk dijalankan pada buku kerja dan arsip produksi.

HTTP pengaturan

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

Jawabannya adalah... JSON: periksa success bendera, lalu ulangi data baris array. Tidak ada file untuk didekode.

Apa perbedaan antara Extract Rows dan yang lainnya? Excel tindakan baris?

Rangkaian baris mencakup fungsi tulis, timpa, dan baca. Pilih berdasarkan apa yang seharusnya terjadi pada buku kerja.

Tindakan vs perilakuApa yang dilakukannya pada buku kerjaApa yang Anda dapatkan kembali
Ekstrak Baris (endpoint ini)Tidak ada, hanya bacaA rowData JSON array, satu objek per baris
Tambahkan BarisMenambahkan atau menyisipkan baris baruBuku kerja yang telah dimodifikasi sebagai Base64
Perbarui BarisMenimpa nilai pada baris yang sudah ada.Buku kerja yang telah dimodifikasi sebagai Base64
Hapus BarisMenghapus barisBuku kerja yang telah dimodifikasi sebagai Base64

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

Contoh muatan

Baca lembar kerja default

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

Bacalah lembar kerja tertentu yang memuat nilai-nilai yang peka terhadap budaya.

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

Tips pengambilan oleh tukang pos

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.

contoh 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

Apa arti dari API kembali?

A JSON hasil yang muatannya adalah rowData susunan.

BidangJenisIsi di dalamnya
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" }
]
}

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 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.

Mengapa mengekstrak? Excel diberikan API alih-alih secara manual?

Cara manualnya adalah dengan membuka buku kerja, memilih rentang, menyalinnya ke suatu tempat, dan membentuk ulang secara manual, satu kali per file, setiap kali penyegaran. API membaca baris yang sama seperti satu permintaan deterministik dan memberikannya kepada Anda JSON bahwa siapa pun language mengurai secara native, tanpa Excel instalasi di server. Karena sumbernya tetap standar Kantor Buka XML Karena buku kerja dan operasinya hanya baca, panggilan yang sama aman untuk dijalankan sesuai jadwal terhadap file aktif.

Tindakan terkait

Tugas yang sama di platform lain

Dapatkan Bantuan