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

ワークシートを削除 Excel で Power Automate

PDF4me ワークシートを削除する は Power Automate 1枚以上のシートを Excel ワークブックを名前、インデックス、またはその両方で、一度の呼び出しで指定できます。テンプレートからサンプルシートを削除したり、レポートを配布する前に一時的な計算タブを削除したり、古いワークシートタブをスケジュールに基づいてクリーンアップしたりするのに使用できます。これらはすべて、ワークブックを開くことなく実行できます。 Excel。

このアクションが何をするか

PDF4me ワークシートを削除する 取る Excel ファイルとワークシート名、ワークシートインデックス、またはその両方のリストを指定すると、該当するシートが削除されたブックが返されます。有効なブックには必ず少なくとも1つのワークシートが残っている必要があるため、すべてのワークシートを削除しようとする要求は、組み込みの安全チェックによってブロックされます。

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

認証 API リクエスト​

アクセスするには PDF4me ウェブ API を通して Power Automateすべてのリクエストには有効な API キー。認証はあなたの身元を検証し、コネクタがアクセスできるようにします。 PDF4meの Excel ワークフローからワークシートを削除するサービス。

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

ワークシートのインデックスはここでは1から始まります
インデックス 1 は最初のワークシート、インデックス 2 は 2 番目のワークシート、といった具合です。この操作では、他の操作とは異なり、1 から始まるインデックスを使用します。 PDF4me Excel 行動。
少なくとも1枚のワークシートが残っている必要があります
ワークブック内のすべてのワークシートを削除する要求は、エラーで拒否されます。 Excel 少なくとも1枚の用紙が必要です。
名前とインデックスの選択が結合してユニオンになります
両方のフィールドに入力されている場合、どちらか一方のリストに一致するワークシートはすべて一度ずつ削除され、両方に一致するワークシートだけが削除されるわけではありません。
Power Automate PDF4me Excel の「ワークシートの削除」アクションで、ファイルコンテンツ、ファイル名、ワークシート名、ワークシートインデックスの各フィールドが表示されます。

以前のアクションからファイルの内容とファイル名をマッピングし、ワークシート名やワークシートインデックスを設定して、削除するシートを選択します。

パラメータ​

必須: ファイルの内容とファイル名は必ず指定する必要があります。ワークシート名またはワークシートインデックスの少なくとも1つは、削除対象のシートを特定するものでなければならず、削除後も少なくとも1つのワークシートが残っている必要があります。

パラメータ必須その機能例
File ContentOptionalContent of the Excel file to process. Map it from the file content returned by a previous action, such as SharePoint or OneDrive Get file content.@{body('Get_file_content')?['$content']}
File NameOptionalName of the Excel file, including its extension (for example `report.xlsx`). Map it from the file name returned by a previous action. Defaults to `DeleteWorksheets.xlsx`.report.xlsx
Worksheet NamesOptionalComma-separated list of worksheet names to delete ( e.g. Sheet1,Sheet3 ).your value
Worksheet IndexesOptionalComma-separated list of worksheet indexes (1-based) to delete ( 1,2,3).your value

ワークシートを削除すると何が返されますか?​

分野タイプ内容物
documentFile contentContent of the Excel file with the worksheets deleted. Map it into the next action, for example the File Content field of SharePoint or OneDrive Create file.
SuccessYes/NoWhether the operation completed successfully
ErrorMessageTextError message if operation failed
ErrorsArrayList of detailed error messages
{
"document": "<file content>",
"Success": true,
"ErrorMessage": null,
"Errors": []
}

よくあるエラーメッセージ​

エラーメッセージ原因解決
Request is emptyRequest object is null.Provide a valid request object.
Document is emptyDocument object is null.Provide a valid Excel document.
Invalid worksheet selectionWorksheet name doesn't exist or index is out of range.Use valid worksheet names, or valid 1-based indexes.
Available worksheets in workbook (X total)Informational message appended when worksheet selection validation fails.Review worksheet names or indexes and use valid values from the X available worksheets listed.
Cannot delete all worksheets. At least one worksheet must remain.The combined selection matches every worksheet in the workbook.Remove at least one worksheet from the deletion list so one sheet remains.

ワークシートの削除を設定する方法 Power Automate?​

  1. 追加 PDF4me → ワークシートを削除する あなたの Power Automate 流れ。
  2. 地図 ファイルの内容 そして ファイル名 以前のアクションから、例えば SharePoint または OneDrive ファイルの内容を取得します。
  3. セット ワークシート名、 ワークシート索引または両方を使用して、取り外すシートを特定します。
  4. フローを実行する。 PDF4me 一致するワークシートを削除し、更新されたワークブックを返します。 documentすべてのシートを削除するような要求の場合は、その要求をブロックします。

ワークシートは名前で選択すべきですか、それともインデックスで選択すべきですか?​

使用 ワークシート名 削除するシートに「Sample1」や「Draft」などの安定した既知の名前が付いている場合、後でシートの順序が変更されても選択が正しく維持されるため、この方法を使用します。 ワークシート索引 フローがシートの順序は予測可能だが名前が可変のワークブックを生成する場合、ここでのインデックスは 1ベース両方を設定すると、2 つの選択範囲の和集合が削除されるため、それらが重なってもエラーは発生せず、そのワークシートが一度だけ削除されます。

典型的な構成​

ワークフローの例Common Power Automate flow patterns using Delete Worksheets from Excel.
新入社員向けオンボーディング用テンプレートの整理
  1. 人事システムに新しい従業員レコードが作成されると、フローがトリガーされます。
  2. 「ファイルの取得」は、ドキュメントライブラリからマスター経費報告書テンプレートを取得します。
  3. 「ワークシートを削除」は、「ワークシート名」を「Sample1,Sample2,Instructions」に設定して実行され、プレースホルダーシートを削除します。
  4. 整理されたテンプレートは、新入社員に必要な「経費」タブと「領収書」タブのみを残して、新入社員にメールで送信されます。
配布前の報告書の最終化
  1. 月次レポート生成フローが完了し、作業用レポートが生成されます。 Excel ファイル。
  2. Get File はレポートを取得します SharePoint。
  3. 「ワークシートの削除」を実行すると、内部の「計算」、「生データ」、「下書き」タブが名前で削除され、「概要」と「グラフ」のみが残ります。
  4. 最終版ファイルは、内部作業シートを公開することなく、経営陣にメールで送信される。
予定されているアーカイブワークシートのクリーンアップ
  1. 繰り返しトリガーは、過去12か月間のレポートに基づいて四半期ごとにアーカイブフローを実行します。
  2. Get Fileは、毎月1枚のワークシートを蓄積するローリングレポートを取得します。
  3. 「ワークシートの削除」では、最も古い四半期の月別タブが名前で識別され(例:「Jan2026,Feb2026,Mar2026」)、削除されます。
  4. トリミングされたワークブックは、 SharePointファイルサイズを管理しやすい範囲に抑える。

実践的なヒント​

Double-check the index base before mapping a value
Delete Worksheets uses 1-based indexes, so index 1 is the first sheet. Other PDF4me Excel actions use 0-based indexing; mixing the two up is the most common source of the wrong sheet being deleted.
Match Worksheet Names exactly, including case
Worksheet name comparison is case-sensitive. A mismatch returns an invalid worksheet selection error even if the name looks correct at a glance.
Always leave one worksheet standing
Build the deletion list so at least one sheet survives. Attempting to delete every worksheet fails outright rather than leaving an empty workbook.
Combining names and indexes extracts a union, not an intersection
If a worksheet matches either list, it is removed once. Use only one selection method if you need a fully predictable deletion set.
Read the error message for the available worksheet list
An invalid worksheet selection error includes the workbook's actual worksheet names or count, which is faster to debug against than guessing at a typo.

チートシート​

分野価値
ActionDelete Worksheets
File ContentMapped from a prior file-retrieval action
File Namee.g. data.xlsx
Worksheet NamesComma-separated, case-sensitive
Worksheet Indexes1-based, comma-separated
At least one requiredWorksheet Names or Worksheet Indexes must be set
Both filledUnion of name matches and index matches
Safety checkBlocks deletion if it would remove every worksheet
OutputProcessed File Content, Success, Error Message, Error Details

よくある質問​

How do I delete a worksheet from Excel in Power Automate?+
Add the PDF4me Delete Worksheets action, map File Content and File Name from a prior action, then set Worksheet Names, Worksheet Indexes, or both to choose which sheets to remove. The action returns the updated workbook with the matching worksheets deleted.
Are Worksheet Indexes 0-based or 1-based in Delete Worksheets?+
Worksheet Indexes are 1-based in this action, so index 1 refers to the first worksheet, index 2 to the second, and so on. This differs from some other PDF4me Excel actions, so check the field's placeholder text before mapping a value. See <a href="https://learn.microsoft.com/en-us/connectors/pdf4me/" target="_blank" rel="noopener noreferrer">the PDF4me Power Automate connector reference</a> for the full action list.
What happens if I try to delete every worksheet in a workbook?+
The action blocks the request and returns an error, because a valid Excel workbook must always contain at least one worksheet. Adjust the Worksheet Names or Worksheet Indexes list so at least one sheet remains.
Can I select worksheets by name and by index in the same request?+
Yes. If both Worksheet Names and Worksheet Indexes are provided, the action deletes the union of the two selections, so any worksheet matching either list is removed once, even if it appears in both.
What if a worksheet name or index does not exist in the workbook?+
The action returns an invalid worksheet selection error naming the missing sheet, along with the worksheets actually available in the workbook. See <a href="https://learn.microsoft.com/en-us/office/vba/api/excel.worksheets" target="_blank" rel="noopener noreferrer">Microsoft's Worksheets collection reference</a> for how Excel itself models worksheet collections.

業界におけるユースケースとアプリケーション​

財務・会計におけるユースケース

  • テンプレート配布: 新規ユーザーに送信する前に、会計テンプレートからサンプルワークシートを削除してください。
  • レポートの最終化配布前に財務報告書から計算ワークシートを削除する
  • 期間終了: 月次レポートから前期のワークシートを削除する
  • 監査準備監査成果物から内部レビューワークシートを削除する

関連アクション​

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

ヘルプが必要な場合​