メインコンテンツへスキップ

ワークシートを抽出する Excel

PDF4me ワークシートを抽出する は REST 選択したシートを読み込むエンドポイント Excel ワークブックに書き込み、新しいワークブックコンテンツとして返します。 POST ファイルとして Base64 に office/ApiV2Excel/ExcelExtractWorksheetシートに名前を付けるか、0から始まるインデックスを一覧表示して、デコードされた結果を保存します。セレクターを送信しない場合は、すべてのワークシートが抽出されます。

このエンドポイントの機能

ワークブックをシートごとに分割します。ファイル全体を一度送信し、分割したいシートを指定します。 extractWorksheetToExcelアクション: 正確なタブ名(大文字小文字を区別)、0 ベースのインデックス、またはその両方を同時に指定できます(結合が実行されます)。レポートの配布、チームごとの分割、および受信者が自分のシートのみを表示する必要があるワークフローにおいて、手動で右クリックして移動またはコピーする手順を置き換えます。

関連ブログ記事
この機能に関するブログ記事はまだありません。近日公開予定です。
その間、PDF4me ブログを閲覧して、あらゆるプラットフォームのチュートリアルやワークフローをご覧ください。
ブログをご覧ください →

認証 API リクエスト​

毎 PDF4me REST 電話にはあなたの API キー Authorization ヘッダーを基本認証として設定します。開発者ダッシュボードからキーを取得またはローテーションしてください。

終点​

POSToffice/ApiV2Excel/ExcelExtractWorksheet

見逃してはならない重要な事実​

名前 + インデックス = 和集合、どちらでもない = すべて
提供する ワークシート名、 ワークシートインデックス、または両方。どちらかのリストに一致するシートが抽出されます。両方を省略すると、すべてのワークシートが抽出されますが、これは対象を絞った分割では望ましくない動作です。
インデックスは0から始まり、名前は大文字と小文字を区別します。
インデックス 0 は最初のシート タブです。実際のタブと大文字小文字が異なる名前は何も一致しないため、出力にシートが予期せず見つからない場合は、通常は大文字小文字の不一致であり、 API エラー。
オフィス API 家族、異なる道の形
Excel オペレーションは office/ApiV2Excel/ 同じホスト上、 /api/v2/.本体もネストされています:アクションオブジェクト(extractWorksheetToExcelアクション) 平坦なルートフィールドの代わりに。

HTTP 設定​

方法: POST
URL: https://api.pdf4me.com/office/ApiV2Excel/ExcelExtractWorksheet
コンテンツタイプ: アプリケーション/json
Authorization: 基本 <あなたの PDF4me API キー>

回答は JSON: チェック success フラグを立てて、それから Base64返されたワークブックの内容をデコードして保存します。 .xlsx 拡大。

どのシートが抽出されるか:名前か、それとも索引か?​

選択は宣言型です。並べ替えやループ処理は一切不要です。対象シートを一度記述すれば、エンジンがワークブックに対してそれらを解決します。

名前とインデックス送信抽出されるもの
名前のみ"worksheetNames": ["Sheet1", "Summary"]タブ名が完全に一致するシート(大文字と小文字を区別)
索引のみ"worksheetIndexes": [0, 2]0から始まる位置にあるシート
両方名前+索引組合: どちらかのリストに一致するもの
どちらでもない{} アクションオブジェクトワークブック内のすべてのワークシート

API ボディフィールド​

パラメータ必須その機能例
documentRequiredSource file. `Name` must end in `.xlsx`, `.xls` or `.xlsm` (a `.csv` for `ExcelParseCsv`).{ "Name": "data.xlsx" }
document.NameRequiredFile name including its extension. Type: string.{ "Name": "data.xlsx" }
docContentRequiredThe source file, base64-encoded. Type: string.UEsDBBQABgAIAAAA...
isAsyncOptionalProcess the request in the background. The call returns `202 Accepted`; poll the `Location` URL (`GetActionStatus`) for the result. Type: boolean.
extractWorksheetToExcelActionRequiredObject carrying this operation's settings. Its fields are the extractWorksheetToExcelAction rows below.{ "worksheetNames": [...] }
extractWorksheetToExcelAction.worksheetNamesOptionalComma-separated worksheet names. Type: string.
extractWorksheetToExcelAction.worksheetIndexesOptionalComma-separated 1-based worksheet numbers, e.g. `"1,3"`. Type: string.

サンプルペイロード​

名前で2枚のシートを抽出する​

{
"document": { "Name": "data.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"extractWorksheetToExcelAction": {
"worksheetNames": ["Sheet1", "Summary"]
}
}

0ベースのインデックスによる抽出​

{
"document": { "Name": "data.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"extractWorksheetToExcelAction": {
"worksheetIndexes": [0, 2]
}
}

郵便配達員の集荷に関するヒント​

Headers
Content-Type: application/json + Authorization: Basic <apiKey>.
Body
raw JSON. Note the nesting: selectors go INSIDE extractWorksheetToExcelAction, not at the root.
Response
JSON with a success flag and Base64 workbook content. Decode the content before saving as .xlsx.
Sheet names
Copy tab names from Excel exactly. Case matters, and a non-matching name is skipped silently rather than raising an error.

curlの例​

curl -X POST https://api.pdf4me.com/office/ApiV2Excel/ExcelExtractWorksheet \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"document": { "Name": "data.xlsx" },
"docContent": "'"$(base64 -w 0 data.xlsx)"'",
"extractWorksheetToExcelAction": {
"worksheetNames": ["Summary"]
}
}' \
--output response.json

何が API 戻る?​

A JSON 抽出結果を記述し、新しいワークブックの内容を保持する Base64。

分野タイプ内容物
document / documentsString (Base64) / ArrayThe extracted workbook content. A single extraction returns one document; multi-sheet extraction can return an array, so handle both shapes.
fileNameStringOutput filename for the extracted workbook.
successBooleantrue when extraction succeeded. Check this before decoding content.
errorMessageStringPopulated when success is false; explains what went wrong.

コードサンプル​

Excel オフィスエンドポイントはまだパーlanguage サンプルフォルダ。サンプルリポジトリには、すべてのサンプルで使用されるリクエストパターンが含まれています。 PDF4me エンドポイントファミリー:

よくある質問​

How do I extract a single sheet from an Excel workbook?+
Send the workbook as Base64 in docContent and put the sheet name in extractWorksheetToExcelAction.worksheetNames, for example ["Summary"]. The API returns a new workbook containing only that sheet.
What happens if I provide both worksheetNames and worksheetIndexes?+
The selections combine as a union: any sheet matching either a listed name or a listed index is extracted. If you provide neither field, every worksheet in the workbook is extracted.
Are worksheet indexes 0-based or 1-based?+
0-based. Index 0 is the first worksheet, index 1 the second, and so on. This matches the PDF4me Extract Worksheets documentation across platforms.
Are worksheet names case-sensitive?+
Yes. The name must match the sheet tab exactly, including case. A name that does not match any sheet is simply not extracted, so an unexpectedly missing sheet usually means a case mismatch rather than an API error.
Why is this endpoint not under /api/v2/?+
Excel operations belong to the PDF4me office API family, addressed as office/ApiV2Excel/ plus the action name on the same api.pdf4me.com host, with the same Basic Authorization header.
Does extraction change the source workbook?+
No. The source file you send is only read. The extracted sheets are returned as new workbook content in the response; nothing is written back to your original.
Can I extract every sheet into its own file?+
Sending an empty action object extracts all worksheets. For strict one-file-per-sheet splits, iterate your sheet list and call the endpoint once per name; each call returns a workbook containing just that sheet.

ワークシートを抽出する理由 API 手動で行う代わりに?​

手動ルートは ワークシートを移動またはコピー Excelタブを右クリックし、「移動またはコピー」を選択し、「コピーを作成」にチェックを入れ、新しいファイルとして保存します。これをシートごと、ワークブックごと、レポートサイクルごとに繰り返します。 API このループは、分割ごとに1つの決定論的なリクエストに置き換えられます。これは、ワークブックがスケジュール通りに届き、分割されたデータが他のシステムに供給される場合に最適です。出力は標準のままです。 オフィス営業中 XML ワークブック ExcelLibreOfficeとGoogleスプレッドシートがすべて開きます。

関連アクション​

他のプラットフォームでも同じタスクを実行​

ヘルプが必要な場合​