行を抽出する Excel
PDF4me 行を抽出する は REST ワークシートの行を読み取るエンドポイント Excel ワークブックを作成し、構造化された形式で返します。 JSON。 POST .xlsx を Base64 に office/ApiV2Excel/ExcelExtractRowsアクションオブジェクトでワークシートと行範囲をスコープし、 rowData 配列です。ファイルではなくデータを返します。 document nullを返します。
ワークシートのスライスを JSON 配列: 各行は 1 つのオブジェクトになります 行データデータベース挿入の準備が整い、 API 呼び出し、またはレポート。これは、Add Rows および Update Rows の読み取り専用対応物であり、 API-側でのエクスポートに相当するもの Excel データを開くことなく Excel変更されたファイルは生成されません。
認証 API リクエスト
毎 PDF4me REST 電話にはあなたの API キー Authorization ヘッダーを基本認証として設定します。開発者ダッシュボードからキーを取得またはローテーションしてください。
終点
office/ApiV2Excel/ExcelExtractRows見逃してはならない重要な事実
書類 そして fileName 設計上 null を返します。 Base64 そこにあるファイルは壊れます。HTTP 設定
方法: POST
URL: https://api.pdf4me.com/office/ApiV2Excel/ExcelExtractRows
コンテンツタイプ: アプリケーション/json
Authorization: 基本 <あなたの PDF4me API キー>
回答は JSON: チェック success フラグを、次に反復します 行データ 配列。デコードするファイルがありません。
「Extract Rows」は他の機能とどう違うのですか? Excel 行の操作?
行ファミリーには、書き込み、上書き、読み取りが含まれます。ワークブックに対してどのような処理を実行するかに応じて選択してください。
| 行動と振る舞い | ワークブックにどのような影響を与えるか | 返ってくるもの |
|---|---|---|
| 行を抽出する(このエンドポイント) | 何もなし、読み取り専用 | A rowData JSON 配列、1行につき1つのオブジェクト |
| 行を追加する | 新しい行を追加または挿入します | 変更されたワークブックとして Base64 |
| 行を更新する | 既存の行の値を上書きします | 変更されたワークブックとして Base64 |
| 行を削除する | 行を削除します | 変更されたワークブックとして Base64 |
API ボディフィールド
| パラメータ | 必須 | その機能 | 例 |
|---|---|---|---|
| document | Required | Source file. `Name` must end in `.xlsx`, `.xls` or `.xlsm` (a `.csv` for `ExcelParseCsv`). | { "Name": "data.xlsx" } |
| document.Name | Required | File name including its extension. Type: string. | { "Name": "data.xlsx" } |
| docContent | Required | The source file, base64-encoded. Type: string. | UEsDBBQABgAIAAAA... |
| isAsync | Optional | Process the request in the background. The call returns `202 Accepted`; poll the `Location` URL (`GetActionStatus`) for the result. Type: boolean. | |
| extractRowsToExcelAction | Required | Object carrying this operation's settings. Its fields are the extractRowsToExcelAction rows below. | {} |
| extractRowsToExcelAction.worksheetName | Optional | The sheet to read. Defaults to the first sheet. Type: string. | |
| extractRowsToExcelAction.hasHeaderRow | Optional | Use the first row as the property names. Type: boolean. | |
| extractRowsToExcelAction.firstRow | Optional | 0-based first row to read. Type: integer. | |
| extractRowsToExcelAction.lastRow | Optional | 0-based last row to read. `-1` is the last row with data. Type: integer. | |
| extractRowsToExcelAction.firstColumn | Optional | 0-based first column to read. Type: integer. | |
| extractRowsToExcelAction.lastColumn | Optional | 0-based last column to read. `-1` is the last column with data. Type: integer. | |
| extractRowsToExcelAction.excludeEmptyRows | Optional | Skip empty rows. Type: boolean. | |
| extractRowsToExcelAction.excludeHiddenRows | Optional | Skip hidden rows. Type: boolean. | |
| extractRowsToExcelAction.excludeHiddenColumns | Optional | Skip hidden columns. Type: boolean. | |
| extractRowsToExcelAction.exportValuesAsText | Optional | Return numbers as text. Type: boolean. | |
| extractRowsToExcelAction.exportEmptyCells | Optional | Include empty cells as `""`. Type: boolean. | |
| extractRowsToExcelAction.culture | Optional | Culture used to format values. Type: string. | |
サンプルペイロード
デフォルトのワークシートを読み込む
{
"document": { "Name": "data.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"extractRowsToExcelAction": {}
}
文化を意識した価値観が記載されたワークシートを読んでください。
{
"document": { "Name": "sales.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"extractRowsToExcelAction": {
"worksheetName": "Q3",
"cultureName": "en-US"
}
}
郵便配達員の集荷に関するヒント
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
何が API 戻る?
A JSON ペイロードが rowData 配列。
| 分野 | タイプ | 内容物 |
|---|---|---|
rowData | Array of objects | The primary output. Each entry is one extracted row as a JSON object, with column names or indexes as keys. |
success | Boolean | true when extraction succeeded. Check this before iterating rowData. |
document | null | Null for this endpoint: no modified file is produced. Present only because the office family shares one response shape. |
fileName | null | Null for this endpoint, for the same reason as document. |
errorMessage | String | Populated 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" }
]
}
コードサンプル
Excel オフィスエンドポイントはまだパーlanguage サンプルフォルダ。サンプルリポジトリには、すべてのサンプルで使用されるリクエストパターンが含まれています。 PDF4me エンドポイントファミリー:
よくある質問
なぜ抽出するのか Excel 譲渡された API 手動で行う代わりに?
手動の方法では、ワークブックを開き、範囲を選択し、それをどこかにコピーし、手動で形状を変更する必要があり、これはファイルごと、更新ごとに1回ずつ行われます。 API 1 つの決定論的リクエストと同じ行を読み取り、 JSON いかなるものも language ネイティブに解析し、 Excel サーバーへのインストール。ソースは標準のままなので オフィス営業中 XML ワークブックと読み取り専用の操作であれば、同じ呼び出しをライブファイルに対してスケジュール実行しても安全です。