行を更新 Excel
PDF4me 行を更新する は REST 書き込みを行うエンドポイント JSON データを既存の行に挿入する Excel ワークブック。 POST .xlsx を Base64 に office/ApiV2Excel/ExcelUpdateRows データと共に jsonInput、対象行 Excel テーブル名または1ベースの座標で指定し、更新されたワークブックをデコードします。 JSON 応答。数値と日付の変換はデフォルトで自動的に行われます。
ワークブックと JSON オブジェクトの配列を取得し、それらの値を既存の行に書き込みます。料金表の価格を更新したり、レポートのレコードを修正したり、 CRM2 つのターゲティング モードのいずれかを使用して、データの送信先を選択します。 Excel テーブルまたは正確な行と列の座標。応答は JSON 更新されたワークブックとして Base64 コンテンツ。
認証 API リクエスト
毎 PDF4me REST 電話にはあなたの API キー Authorization ヘッダーを基本認証として設定します。開発者ダッシュボードからキーを取得またはローテーションしてください。
終点
office/ApiV2Excel/ExcelUpdateRows見逃してはならない重要な事実
jsonInputこのエンドポイントで400エラーが発生する最も一般的な原因は、生の配列を送信することです。まずシリアライズしてから埋め込んでください。テーブル名 テーブルモードに切り替えて excelRowNumber; 空欄の場合は座標モードを意味します insertFromRow/insertFromColumnすべてのポジションは1ベースです。fileName、 success、 そして エラーメッセージ保存する前にデコードしてください。生のレスポンスは有効な .xlsx ファイルではありません。HTTP 設定
方法: POST
URL: https://api.pdf4me.com/office/ApiV2Excel/ExcelUpdateRows
コンテンツタイプ: アプリケーション/json
Authorization: 基本 <あなたの PDF4me API キー>
回答は JSON: チェック success フラグを立てて、それから Base64返されたワークブックの内容をデコードして保存します。 .xlsx 拡大。
テーブルモードと座標モードのどちらを使うべきでしょうか?
これら2つのモードは異なるワークシートレイアウトに対応しており、どちらかを間違えて選択すると、更新内容が間違ったセルに反映されてしまうのが一般的です。
| テーブルモードと座標モードの比較 | テーブルモード | 座標モード |
|---|---|---|
| 選び方 | セット tableName 指定された Excel テーブル | 離れる tableName 空の |
| データがどこに着地するか | 行 excelRowNumber テーブル内(1ベース) | 開始価格 insertFromRow/insertFromColumn (1を基数としているので、1/1はA1です) |
| 列のマッチング | JSON プロパティ名はテーブルの列ヘッダーに対応します | 値は開始列から左から右に書き込まれます |
| レイアウト変更にも耐える | はい、テーブルが移動すれば、更新もそれに従います。 | いいえ、座標は固定位置です |
| 最適 | 実際の例を含む構造化されたワークシート Excel テーブル | プレーンレンジとアドホックシート |
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. | |
| updateRowsToExcelAction | Required | Object carrying this operation's settings. Its fields are the updateRowsToExcelAction rows below. | { "jsonInput": "..." } |
| updateRowsToExcelAction.jsonData | Optional | The new values, as a JSON array of objects encoded in a string. Type: string. | |
| updateRowsToExcelAction.worksheetName | Optional | The sheet to update. Type: string. | |
| updateRowsToExcelAction.startRow | Optional | 1-based first row to write to. Type: integer. | |
| updateRowsToExcelAction.startColumn | Optional | 1-based first column to write to. Type: integer. | |
| updateRowsToExcelAction.convertNumericAndDate | Optional | Store numbers and dates as real Excel values. Type: boolean. | |
| updateRowsToExcelAction.dateFormat | Optional | Format for date values. Type: string. | |
| updateRowsToExcelAction.numericFormat | Optional | Format for numbers. Type: string. | |
| updateRowsToExcelAction.ignoreNullValues | Optional | Leave a cell unchanged when its value is `null`. Type: boolean. | |
| updateRowsToExcelAction.cultureName | Optional | Culture used to format numbers and dates. Type: string. | |
サンプルペイロード
テーブルモード:名前付きテーブルの5行目を更新する
{
"document": { "Name": "sales.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"updateRowsToExcelAction": {
"jsonInput": "[{\"Region\":\"EMEA\",\"Revenue\":125000}]",
"worksheetName": "Q3",
"tableName": "SalesTable",
"excelRowNumber": 5
}
}
座標モード:セル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"
}
}
郵便配達員の集荷に関するヒント
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
何が API 戻る?
A JSON 更新されたワークブックを結果として Base64。
| 分野 | タイプ | 内容物 |
|---|---|---|
document | String (Base64) | The updated workbook content. Decode to bytes and save with an .xlsx extension. |
fileName | String | Output filename for the updated workbook. |
success | Boolean | true when the update succeeded. Check this before decoding content. |
errorMessage | String | Populated when success is false: malformed jsonInput, a missing table or worksheet, or invalid Base64. |
出力は標準のままです オフィス営業中 XML ワークブックは更新されるため、更新されたセル以外の数式、書式設定、およびシートは変更されません。
コードサンプル
Excel オフィスエンドポイントはまだパーlanguage サンプルフォルダ。サンプルリポジトリには、すべてのサンプルで使用されるリクエストパターンが含まれています。 PDF4me エンドポイントファミリー:
よくある質問
アップデートする理由 Excel 行 API 手動で行う代わりに?
手動で行う方法は、各ワークブックを開き、行を見つけて、値を再入力して保存することです。一度は機能するかもしれませんが、毎晩の同期には機能しません。 CRM またはデータベース。 API ファイルごとに 1 つの決定論的リクエストと同じ編集を行い、 Excel テーブル 無傷で、 Excel サーバーにインストールされています。出力は標準です。 オフィス営業中 XML 次のステップに進むためのワークブックが完成しました。